import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
+import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.user.client.Element;
this.isVertical = isVertical;
}
- public void addSlot(VLayoutSlot layoutSlot) {
+ public void addOrMove(VLayoutSlot layoutSlot, int index) {
Widget widget = layoutSlot.getWidget();
Element wrapperElement = layoutSlot.getWrapperElement();
- getElement().appendChild(wrapperElement);
- add(widget, wrapperElement);
+ Element containerElement = getElement();
+ Node childAtIndex = containerElement.getChild(index);
+ boolean alreadyAttached;
+ if (childAtIndex != wrapperElement) {
+ alreadyAttached = wrapperElement.getParentElement() == containerElement;
+ containerElement.insertBefore(wrapperElement, childAtIndex);
+ } else {
+ alreadyAttached = true;
+ }
+ if (!alreadyAttached) {
+ insert(widget, wrapperElement, index, false);
+ }
widget.setLayoutData(layoutSlot);
}
ValueMap expandRatios = uidl.getMapAttribute("expandRatios");
ValueMap alignments = uidl.getMapAttribute("alignments");
+ int currentIndex = 0;
// TODO Support reordering elements!
for (final Iterator<Object> it = uidl.getChildIterator(); it.hasNext();) {
final UIDL childUIDL = (UIDL) it.next();
if (widget.getParent() != layout) {
slot = new VPaintableLayoutSlot(getWidgetForPaintable()
.getStylePrimaryName(), child);
- layout.addSlot(slot);
}
+ layout.addOrMove(slot, currentIndex++);
String pid = child.getId();