/** * Starts the preview animation with the given {@code delay} between frames. * Add the frames using {@link #addImage(String)} method before starting the * preview. */ public void startPreview(int delay) { frameTimer = new Timer() { private int currentFrame; @Override public void run() { WidgetCollection frames = getChildren(); for (int i = 0; i < frames.size(); i++) { frames.get(i).setVisible(i == currentFrame); } currentFrame++; if (currentFrame >= frames.size()) { currentFrame = 0; } } }; frameTimer.scheduleRepeating(delay); }
private SelectionChoiceButton getButton() { WidgetCollection children = getChildren(); // each grid element panel should contain only one child ex. button if (children.size() != 1) { throw new RuntimeException("SelectionGridElement panel contains " + children.size() + " elements when 1 was expected!"); } SelectionChoiceButton button = (SelectionChoiceButton) children.get(0); return button; }
/** * @return The latest remaining (bottom most) ListBox */ @Override public UserListBox getLatestListBox() { UserListBox latestListBox = null; WidgetCollection children = this.getChildren(); for (int index = children.size() - 1; index >= 0; index--) { Widget widget = children.get(index); if (widget instanceof UserListBox) { latestListBox = (UserListBox) widget; index = -1; // break out of for-loop } } return latestListBox; }
@Override public Vector<UserListBox> getListBoxes() { Vector<UserListBox> listBoxes = new Vector<UserListBox>(); WidgetCollection children = this.getChildren(); for (int index = 0; index < children.size(); index++) { Widget widget = children.get(index); if (widget instanceof UserListBox) { listBoxes.add((UserListBox) widget); } } return listBoxes; }
void doLogicalClear() { if (orphanCommand == null) { orphanCommand = new AttachDetachException.Command() { public void execute(Widget w) { orphan(w); } }; } try { AttachDetachException.tryCommand(this, orphanCommand); } finally { children = new WidgetCollection(this); } }
public HTMLStream clearAll() { WidgetCollection childs = getChildren(); while( childs.size() > 0 ) { childs.remove( 0 ); } div.setInnerHTML( "" ); currentParagraph = null; curSet.clear(); curParCurSet.clear(); return this; }
/** * 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. * * @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); }
/** * Selects the specified collection of elements. * * @param nodes * the elements * @return the selection */ public static final Selection selectAll(final WidgetCollection widgets) { List<Element> elements = new ArrayList<Element>(); for (Widget widget : widgets) { elements.add(widget.getElement()); } return selectAll(elements); }
@Override public WidgetCollection getChildren() { return super.getChildren(); }
@Override public void clear() { super.clear(); children = new WidgetCollection(this); dividerList.clear(); }
private void removeAllNotes() { final WidgetCollection kids = getChildren(); while (kids.size() > 0) { remove(kids.size() - 1); } }
/** * Gets the list of children contained in this panel. * * @return a collection of child widgets */ public WidgetCollection getChildren() { return children; }