Search code examples
gwtuibinder

Changing widgets order in UiBinder layout in GWT application


I have a widget declared with UiBinder. Instances of this widget are used widely in application for building different views. My task is to implement a new view where a couple of panels should be reordered.

<g:FlowPanel ui:field="text" styleName="...">
...
<g:FlowPanel>

<g:FlowPanel ui:field="images" styleName="...">
...
</g:FlowPanel>

For the given sample structure I need to put images on top of the text for new custom view. I don't want to duplicate the widget's code. And I don't want to substitute panels with dummy container and then do an addition to that container in the code, as styles are already here and other code that relies on this structure.

What I do now to solve a problem is I wrap these two panels with a container FlowPanel in a UiBinder (which is harmless so far), and depending on the context I do something like the following in the code:

if (isSwapRequired) {
   images.removeFromParent();
   container.insert(images, 0);
}

The question is - is there a more elegant way of doing reordering, or the given approach is good enough?

Thanks.


Solution

  • Ended up using existing simple solution.