layout.addOrMove(slot, currentIndex++);
}
- // TODO: Move this to layout and base it on DOM and "currentIndex"
for (ComponentConnector child : previousChildren) {
- Widget widget = child.getWidget();
if (child.getParent() != this) {
// Remove slot if the connector is no longer a child of this
// layout
- layout.removeSlot(layout.getSlotForChild(widget));
+ layout.removeSlotForWidget(child.getWidget());
}
}
*/
package com.vaadin.terminal.gwt.client.ui;
+import java.util.HashMap;
+import java.util.Map;
+
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Node;
final DivElement spacingMeasureElement;
+ private Map<Widget, VLayoutSlot> widgetToSlot = new HashMap<Widget, VLayoutSlot>();
+
protected VMeasuringOrderedLayout(String className, boolean isVertical) {
DivElement element = Document.get().createDivElement();
setElement(element);
insert(widget, wrapperElement, index, false);
}
- widget.setLayoutData(layoutSlot);
+ widgetToSlot.put(widget, layoutSlot);
}
private void togglePrefixedStyleName(String name, boolean enabled) {
}
}
- public void removeSlot(VLayoutSlot slot) {
+ public void removeSlotForWidget(Widget widget) {
+ VLayoutSlot slot = getSlotForChild(widget);
VCaption caption = slot.getCaption();
if (caption != null) {
// Must remove using setCaption to ensure dependencies (layout ->
remove(slot.getWidget());
getElement().removeChild(slot.getWrapperElement());
+ widgetToSlot.remove(widget);
}
public VLayoutSlot getSlotForChild(Widget widget) {
- Object o = widget.getLayoutData();
- if (o instanceof VLayoutSlot) {
- return (VLayoutSlot) o;
- }
-
- return null;
+ return widgetToSlot.get(widget);
}
public void setCaption(Widget child, VCaption caption) {