List of usage examples for com.google.gwt.user.client.ui WidgetCollection indexOf
public int indexOf(Widget w)
From source file:fi.jasoft.dragdroplayouts.client.ui.VDDHorizontalLayout.java
License:Apache License
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * /*www. j a v a 2 s . c o m*/ * @param widget * The container which we are hovering over * @param event * The drag event */ protected void updateDropDetails(Widget widget, VDragEvent event) { if (widget == null) { // Null check return; } /* * The horizontal position within the cell */ event.getDropDetails().put(Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION, getHorizontalDropLocation(widget, event)); /* * The index over which the drag is. Can be used by a client side * criteria to verify that a drag is over a certain index. */ WidgetCollection widgets = getChildren(); event.getDropDetails().put(Constants.DROP_DETAIL_TO, widgets.indexOf(widget)); /* * Add Classname of component over the drag. This can be used by a a * client side criteria to verify that a drag is over a specific class * of component. */ if (widget instanceof ChildComponentContainer) { Widget w = ((ChildComponentContainer) widget).getWidget(); if (w != null) { String className = w.getClass().getName(); event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, className); } else { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, this.getClass().getName()); } } else { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, this.getClass().getName()); } // Add mouse event details MouseEventDetails details = new MouseEventDetails(event.getCurrentGwtEvent(), VDDHorizontalLayout.this.getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
From source file:fi.jasoft.dragdroplayouts.client.ui.VDDVerticalLayout.java
License:Apache License
/** * Updates the drop details while dragging. This is needed to ensure client * side criterias can validate the drop location. * //from w w w. j av a2 s .com * @param widget * The container which we are hovering over * @param event * The drag event */ protected void updateDropDetails(Widget widget, VDragEvent event) { if (widget == null) { return; } /* * The horizontal position within the cell */ event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION, getVerticalDropLocation(widget, event)); /* * The index over which the drag is. Can be used by a client side * criteria to verify that a drag is over a certain index. */ WidgetCollection widgets = getChildren(); event.getDropDetails().put(Constants.DROP_DETAIL_TO, widgets.indexOf(widget)); /* * Add Classname of component over the drag. This can be used by a a * client side criteria to verify that a drag is over a specific class * of component. */ if (widget instanceof ChildComponentContainer) { Widget w = ((ChildComponentContainer) widget).getWidget(); if (w != null) { String className = w.getClass().getName(); event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, className); } else { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, this.getClass().getName()); } } else { event.getDropDetails().put(Constants.DROP_DETAIL_OVER_CLASS, this.getClass().getName()); } // Add mouse event details MouseEventDetails details = new MouseEventDetails(event.getCurrentGwtEvent(), getElement()); event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT, details.serialize()); }
From source file:geogebra.web.gui.app.docklayout.MyDockLayoutPanel.java
License:Apache License
/** * Adds a widget to the specified edge of the dock. If the widget is already * a child of this panel, this method behaves as though * {@link #remove(Widget)} had already been called. * // ww w .j a va 2 s . co m * @param widget * the widget to be added * @param direction * the widget's direction in the dock * @param before * the widget before which to insert the new child, or * <code>null</code> to append */ protected void insert(Widget widget, Direction direction, double size, Widget before) { assertIsChild(before); // Validation. if (before == null) { assert center == null : "No widget may be added after the CENTER widget"; } else { assert direction != Direction.CENTER : "A CENTER widget must always be added last"; } // Detach new child. widget.removeFromParent(); // Logical attach. WidgetCollection children = getChildren(); if (before == null) { children.add(widget); } else { int index = children.indexOf(before); children.insert(widget, index); } if (direction == Direction.CENTER) { center = widget; } // Physical attach. Layer layer = layout.attachChild(widget.getElement(), (before != null) ? before.getElement() : null, widget); LayoutData data = new LayoutData(direction, size, layer); widget.setLayoutData(data); // Adopt. adopt(widget); // Update the layout. animate(0); }
From source file:org.kaaproject.kaa.server.admin.client.layout.CustomDeckLayoutPanel.java
License:Apache License
/** * Insert a widget before the specified widget. If the widget is already a * child of this panel, this method behaves as though {@link #remove(Widget)} * had already been called./*from www.ja v a 2s . c om*/ * * @param widget the widget to be added * @param before the widget before which to insert the new child, or * <code>null</code> to append */ public void insert(Widget widget, Widget before) { assertIsChild(before); // Detach new child. widget.removeFromParent(); // Logical attach. WidgetCollection children = getChildren(); if (before == null) { children.add(widget); } else { int index = children.indexOf(before); children.insert(widget, index); } // Physical attach. Layer layer = layout.attachChild(widget.getElement(), (before != null) ? before.getElement() : null, widget); setWidgetVisible(widget, layer, false); widget.setLayoutData(layer); // Adopt. adopt(widget); // Update the layout. animate(0); }
From source file:rocket.widget.client.Panel.java
License:Apache License
/** * Attempts to remove an existing widget from this panel if it is a child. * //from w w w . j a va2 s.co m * @return true if the widget was a child and was successfully removed, * otehrwise returns false. */ public boolean remove(final Widget widget) { Checker.notNull("parameter:widget", widget); boolean removed = false; final WidgetCollection widgets = this.getWidgetCollection(); final int index = widgets.indexOf(widget); if (-1 != index) { this.remove(index); removed = true; } return removed; }