Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Flow Layout Bug: Portlet gets deleted while moving it from one flow layout to another

    SmartGWT Version: SmartGWT 3.0ee (not the nightly build)
    SmartClient Version: SC_SNAPSHOT-2012-01-05_v8.2p/Enterprise Deployment (built 2012-01-05)
    [smart client version is copied from the debug console]

    Browser version:
    Firefox 12.0

    Bug location: client side
    A 12 second long bug video with steps on youtube(not public, only those with the link can see it): http://youtu.be/MUwJykIkVOQ

    Bug Information:
    While moving portlets from one flowlayout canvas to another the portlets disappear. I have created a small Poc to reproduce this problem. Steps to reproduce the bug are shown on the youtube link above.
    In my use case I need to create custom dashboards and move portlets from one custom dashboard to another so that user can customize his own dashboard.
    Problem occurs only with TileLayout and FlowLayout. Things work perfectly fine with VLayout which unfortunately does not fit into my use case.

    Stack Trace: no error present in the SmartGwt Console

    Code:
    I have created a POC of two files:
    Here is the code from the 1st file:
    Code:
    package com.poc.tilelayoutpoc.client;
    
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.layout.FlowLayout;
    import com.smartgwt.client.widgets.tab.Tab;
    
    class FlowLayoutTab extends Tab {
    	private FlowLayout mainCanvas;
    	private static int cnt = 0;
    		
    	FlowLayoutTab() {
    		super("PocTab - " + cnt++);
    		
    		mainCanvas = new FlowLayout();
    		mainCanvas.setWidth100();
    		mainCanvas.setHeight100();
    		setPane(mainCanvas);
    	}
    	
    	void addTile(Canvas tile){
    		mainCanvas.addTile(tile);
    	}
    	
    	void removeTile(Canvas tile){
    		mainCanvas.removeTile(tile);
    	}
    }
    Here is the code form the 2nd file:
    Code:
    package com.poc.tilelayoutpoc.client;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.Element;
    import com.google.gwt.user.client.Window;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.Portlet;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.tab.TabSet;
    
    /**
     * Entry point classes define <code>onModuleLoad()</code>.
     */
    class TileLayoutPoc extends VLayout implements EntryPoint {
    
    	private int portletCnt = 0;
    	private static final int TAB_CNT = 5;
    	private HLayout headerPane;
    	private TabSet tabSet;
    	private Map<String,FlowLayoutTab> tabMap;
    	
    	private Map<String,Portlet> portletNameMap;
    	private Map<String,FlowLayoutTab> portletTabMap;
    
    	private SelectItem createPortletTabSelItem;
    	private SelectItem moveToTabSelItem;
    	private SelectItem portletSelItem;
    
    	private IButton createPortletBtn;
    	private IButton movePortletBtn;
    
    	/**
    	 * This is the entry point method.
    	 */
    	public void onModuleLoad() {
    		setWidth100();
    		setHeight100();
    
    		portletNameMap = new HashMap<String, Portlet>();
    		portletTabMap = new HashMap<String, FlowLayoutTab>();
    		
    		initComponents();
    		addTabs();
    		
    		addEventHandlers();
    		draw();
    	}
    
    	private void addEventHandlers() {
    		createPortletBtn.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				Portlet newPortlet = generatePortlet();
    				String tabName = createPortletTabSelItem.getValueAsString();
    				if(tabName==null || tabName.equals("")){
    					Window.alert("Select a tab");
    					return;
    				}
    				FlowLayoutTab tab = tabMap.get(tabName);
    				portletTabMap.put(newPortlet.getTitle(), tab);
    				
    				tab.addTile(newPortlet);
    			}
    		});
    		
    		movePortletBtn.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				String portletName = portletSelItem.getValueAsString();
    				String moveToTabTitle = moveToTabSelItem.getValueAsString();
    				
    				Portlet portlet = portletNameMap.get(portletName);
    				FlowLayoutTab toTab = tabMap.get(moveToTabTitle);
    				FlowLayoutTab fromTab = portletTabMap.get(portletName);
    				
    				fromTab.removeTile(portlet);
    				toTab.addTile(portlet);
    				
    				tabSet.selectTab(toTab);
    			}
    		});
    	}
    
    	private void addTabs() {
    		tabMap = new HashMap<String, FlowLayoutTab>();
    		String titleArr[] = new String[TAB_CNT];
    
    		for (int i = 0; i < TAB_CNT; i++) {
    			FlowLayoutTab flowLayoutTab = new FlowLayoutTab();
    			titleArr[i] = flowLayoutTab.getTitle();
    			tabSet.addTab(flowLayoutTab);
    			
    			tabMap.put(titleArr[i], flowLayoutTab);
    		}
    
    		createPortletTabSelItem.setValueMap(titleArr);
    		moveToTabSelItem.setValueMap(titleArr);
    	}
    
    	private void initComponents() {
    		Element element = RootPanel.get("loadingWrapper").getElement();
    		Element bodyElement = RootPanel.getBodyElement();
    		bodyElement.removeChild(element);
    
    		initHeader();
    
    		tabSet = new TabSet();
    		tabSet.setWidth100();
    		tabSet.setHeight("80%");
    
    		setMembers(headerPane, tabSet);
    	}
    
    	private void initHeader() {
    		headerPane = new HLayout();
    		headerPane.setWidth100();
    		headerPane.setHeight("20%");
    
    		createPortletTabSelItem = new SelectItem("TabSelItem", "Create In Tab");
    		moveToTabSelItem = new SelectItem("ToTabSelItem", "Move To Tab");
    		portletSelItem = new SelectItem("SelPortletItem", "Select Portlet To Move");
    		
    		createPortletBtn = new IButton("Create Portlet");
    		movePortletBtn = new IButton("Move Portlet");
    		
    		//create layout to add components
    		VLayout createPortletLayout = new VLayout();
    		createPortletLayout.setWidth("50%");
    		createPortletLayout.setHeight100();
    		createPortletLayout.setShowEdges(true);
    		createPortletLayout.setEdgeSize(1);
    		
    		DynamicForm form1 = new DynamicForm();
    		form1.setItems(createPortletTabSelItem);
    		createPortletLayout.setMembers(form1,createPortletBtn);
    		
    		VLayout movePortletLayout = new VLayout();
    		movePortletLayout.setWidth("50%");
    		movePortletLayout.setHeight100();
    		movePortletLayout.setShowEdges(true);
    		movePortletLayout.setEdgeSize(1);
    		
    		DynamicForm form2 = new DynamicForm();
    		form2.setItems(portletSelItem,moveToTabSelItem);
    		
    		movePortletLayout.setMembers(form2,movePortletBtn);
    		
    		headerPane.setMembers(createPortletLayout,movePortletLayout);
    	}
    	
    	private Portlet generatePortlet(){
    		Portlet portlet = new Portlet();
    		
    		String title = "Portlet - " + portletCnt++;
    		portlet.setTitle(title);
    		portlet.setWidth(400);
    		portlet.setHeight(200);
    		
    		portletNameMap.put(title, portlet);
    		
    		String[] newNames = new String[portletNameMap.keySet().size()];
    		
    		int k=0;
    		for(String name: portletNameMap.keySet()){
    			newNames[k++] = name;
    		}
    
    		portletSelItem.setValueMap(newNames);
    		return portlet;
    	}
    }
    Here is my Gwt module xml file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <module rename-to='tilelayoutpoc'>
    	<!-- Inherit the core Web Toolkit stuff. -->
    	<inherits name='com.google.gwt.user.User' />
    
    	<!-- Inherit the default GWT style sheet. You can change -->
    	<!-- the theme of your GWT application by uncommenting -->
    	<!-- any one of the following lines. -->
    	<inherits name="com.smartgwt.SmartGwtNoTheme" />
    	<inherits name="com.smartclient.theme.treefrog.TreeFrog" />
    	<!-- <inherits name="com.smartgwt.SmartGwt"/> -->
    	<inherits name="com.smartgwtee.SmartGwtEENoScript" />
    	<inherits name="com.smartgwt.Drawing" />
    	<inherits name="com.smartgwt.Analytics" />
    	<inherits name="com.smartgwtee.tools.Tools" />
    
    	<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
    	<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
    	<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
    
    	<!-- Other module inherits -->
    
    	<!-- Specify the app entry point class. -->
    	<entry-point class='com.poc.tilelayoutpoc.client.TileLayoutPoc' />
    
    	<!-- Specify the paths for translatable code -->
    	<source path='client' />
    
    </module>
    Is there any workaround to get rid of this problem?
    Last edited by sandip.sahoo; 5 Nov 2012, 21:45.

    #2
    We have a developer assigned to take a look. We'll update this thread when we have more information.

    Comment


      #3
      This issue should now be resolved. Please try the next nightly build (dated Nov 9 or greater)

      Regards
      Isomorphic Software

      Comment


        #4
        Can you mention the version? Am I pointing to the right link?

        http://www.smartclient.com/builds/SmartGWT/3.0p/EnterpriseEval

        Regards

        Comment


          #5
          That link should be correct but you can also go here: http://www.smartclient.com/builds

          We have confirmed the fix is present in the latest nightly smartgwtee-3.0p 2012-11-16 and that the given test case works as expected in Firefox 12.0, Safari 6.0.2, and Firefox 16.0.2.

          Comment

          Working...
          X