First I have to say great work in the new layout system I’m so amazed
how simple was solved and how good it is .
My request is to add a setSplitPosition method for the
SplitLayoutPanel class, I did not find an issue for this, so I'm
asking for it here first . The method as you could imagine is to
change the position of the splitter after the split panel was created,
also will be nice if there is an option to animate this.
The following is a proposed solution for this issue, this is how I
solved in my code, is also a good work around for anyone needing this
now.
package com.test.client;
import com.google.gwt.user.client.ui.SplitLayoutPanel;
import com.google.gwt.user.client.ui.Widget;
public class MySplitLayoutPanel extends SplitLayoutPanel{
public void setSplitPosition(Widget widgetBeforeTheSplitter, double
size, boolean animate){
LayoutData layout = (LayoutData)
widgetBeforeTheSplitter.getLayoutData();
layout.oldSize = layout.size;
layout.size=size;
if (animate)
animate(500);
else
forceLayout();
}
}
So you'll just need to add that method to the SplitLayoutPanel class.
Also If you want to test it . Here is the class I used to test it
package com.test.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DockLayoutPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.SplitLayoutPanel;
import com.google.gwt.user.client.ui.TabLayoutPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class GWTTest implements EntryPoint {
/**
* This is the entry point method.
*/
public void onModuleLoad() {
final MySplitLayoutPanel p2 = new MySplitLayoutPanel();
final HTML html = new HTML("<div style='background-color:green'>ss</
div>");
final HTML html2 = new HTML("<div style='background-color:blue'>ss</
div>");
p2.addSouth(html, 0);//This is initially hidden and it will be made
visible
// when the expand button is click
p2.add(html2);
TabLayoutPanel tabPanel = new TabLayoutPanel(2.8, Unit.EM);
tabPanel.add(new HTML("this content"), "this");
tabPanel.add(p2, "that");
tabPanel.add(new HTML("the other content"), "the other");
SplitLayoutPanel p = new SplitLayoutPanel();
p.addWest(new HTML("navigation"), 128);
p.add(tabPanel);
Button button = new Button("Expand");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
p2.setSplitPosition(html, 128,true);
}
});
SimplePanel simplePanel = new SimplePanel();
simplePanel.setWidget(button);
DockLayoutPanel appPanel = new DockLayoutPanel(Unit.EM);
appPanel.addNorth(simplePanel, 2);
appPanel.addSouth(new HTML("footer"), 2);
appPanel.add(p);
RootLayoutPanel.get().add(appPanel);
}
}
Im not sure if it was the best way to solved, but is the only solution
I could find without changing the original class