Programming issue with splitlayoutpanel

50 views
Skip to first unread message

tibo_fr

unread,
Sep 24, 2010, 11:56:53 AM9/24/10
to Google Web Toolkit
Hi everybody!

I'm a green horn in gwt programming - nobod's perfect...
I would like to create a composite widget, laying out with a
splitlayoutpanel, which could work like the Microsoft Windows Explorer
in "Details Mode" with the following characteristics :

- all the widgtets in the splitlayout are west (or east, it's the same
thing) oriented
- there are two scroll bars that cover the entire splitlayout: one
horizontal and one vertical in order to move along the splitlayout
from left/right or from top/bottom (and vice versa).

The trap is that it's impossible to put a splitlayoutpanel within a
scrollpanel!!!

If anybody has a solution, he would be greatly reward : all my
consideration ;)

Thanks a lot!!!

ps : excuse me for my bad english..

tibo_fr

unread,
Oct 5, 2010, 8:03:16 AM10/5/10
to Google Web Toolkit
[RESOLVED]


It's allright I've found a solution.

here it's my source code for a widget that works as the Windows
Explorer in detail mode:
Within the splitlayoutpanel there are labels.
- .ui.xml -

<ui:UiBinder
xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:my="urn:import:org.mbt.client.ui">

<g:DockLayoutPanel ui:field="dockpanel" unit='PX'>
</g:DockLayoutPanel>

</ui:UiBinder>

- .java -
public class SplitLabel extends ResizeComposite
{
interface SplitLabelUiBinder extends UiBinder<DockLayoutPanel,
SplitLabel>{};
private static SplitLabelUiBinder uiBinder =
GWT.create(SplitLabelUiBinder.class);

@UiField DockLayoutPanel dockpanel;

String width, height;
double miniLabelWidth;

SplitLayoutPanel splitLayoutPanel = new SplitLayoutPanel();

/**
* Unique constructeur de la classe
*
* @param width largeur du widget, convention CSS. DOIT etre en
pixels. <strong>Ex: "120px"</strong>
* @param height hauteur du widget, convention CSS. DOIT etre en
pixels. <strong>Ex: "200px"</strong>
* @param labelContent chaine contenant les contenus par defaut
des {@link Label} du widget.
* Le séparateur est un ':' <strong>Ex:
"contenuLabel1:contenuLabel2:contenuLabel3"</strong>
* @param miniLabelWidth largeur minimum des {@link Label} du
widget.
* Bien entendu, selon la taille passée au widget et le nombre de
Labels qu'il contient, ces derniers
* pourront être plus larges.
*/
public @UiConstructor SplitLabel(String width, String height,
String labelContent, double miniLabelWidth)
{
this.width = width;
this.height = height;

initWidget(uiBinder.createAndBindUi(this));

dockpanel.setSize(this.width, this.height);

// on recupere les titres des Label dans un tableau
String[] contentList = labelContent.split(":");
int nbLabel = contentList.length;

//width : largeur du splitLabel
width = width.substring(0, (width.length())-2);
// labelWidth: largeur initiale des Labels
Double labelWidth = new Double(width)/nbLabel;

// labelWidth est soumis à une taille minimale
if(labelWidth < miniLabelWidth)
labelWidth = miniLabelWidth;

for(int i=0; i<nbLabel; i++)
{
splitLayoutPanel.addWest(new Label(contentList[i]),
labelWidth);
}

// the tail of the splitlabel
HTML splitLabelTail = new HTML("");
splitLabelTail.addStyleDependentName("splitLabelTail"); // ex
background-color = red;
splitLayoutPanel.add(splitLabelTail);

// global widget style
splitLayoutPanel.addStyleDependentName("splitLabel");
dockpanel.add(splitLayoutPanel);
}

}


PS : sorry for french comments!
Reply all
Reply to author
Forward
0 new messages