tibo_fr
unread,Oct 5, 2010, 8:03:16 AM10/5/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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!