Hello everyone !
I'm facing a problem.
I want to turn this (in the .ui.xml file, it's a widget) :
Code:
<b:SomeWidget ui:field="someName" />
Into this :
Code:
<a:HelpWrapper text="...">
<b:SomeWidget ui:field="someName" />
</a:HelpWrapper>
So that another widget (HelpWidget) is added on the right side of my first widget.
In order to do it, I wrote a little class called "HelpWrapper" :
Code:
public class HelpWrapper extends Composite implements HasWidgets.ForIsWidget {
/**
* The container
*/
private final HorizontalLayoutContainer container;
/**
* The help icon widget
*/
private HelpWidget helpWidget;
/**
* The wrapped widget
*/
private Widget wrappedWidget = null;
/**
* The constructor
*/
public HelpWrapper() {
// We create & initialize the container
container = new HorizontalLayoutContainer();
// We create & add a spacing between the widget and the quick help
container.add(new LabelToolItem(" "));
// We create & add the quick help widget
helpWidget = new HelpWidget();
container.add(helpWidget);
initWidget(container);
}
/**
* @param text
* The tooltip text
*/
public void setText(String text) {
if (helpWidget != null) {
helpWidget.setTooltipHTML(text);
}
}
/**
* @param size
* The size of the icon
*/
public void setSize(IconSize size) {
helpWidget.resizeIcon(size);
}
@Override
public void add(Widget w) {
// We add the widget and the help widget
if (wrappedWidget == null) {
wrappedWidget = w;
container.insert(wrappedWidget, 0);
container.add(new LabelToolItem(" "));
container.add(helpWidget);
}
}
@Override
public void clear() {
// We clear the container
container.clear();
}
@Override
public Iterator<Widget> iterator() {
return container.iterator();
}
@Override
public boolean remove(Widget w) {
boolean ok = container.remove(w);
if (ok) {
wrappedWidget = null;
}
return ok;
}
@Override
public void add(IsWidget w) {
add(w.asWidget());
}
@Override
public boolean remove(IsWidget w) {
return remove(w.asWidget());
}
}
But for some reason, the height of the original widget is not preserved :-(
From this :
base.png
I get this :
fail.png
But what I wanted is this :
win.png
What did I do wrong :-( ?
Thank you in advance !