List of usage examples for com.google.gwt.user.client.ui Widget removeFromParent
public void removeFromParent()
From source file:asquare.gwt.tk.client.ui.ExposedCellPanel.java
License:Apache License
/** * Adds a widget to the panel, optionally creating a new cell. * //from w w w . j a v a 2 s . c o m * @param w a widget * @param newCell <code>true</code> to create a new cell, * <code>false</code> to append to the last cell * @throws IndexOutOfBoundsException if <code>newCell</code> is * <code>false</code> and no cells exist */ public void addWidget(Widget w, boolean newCell) { /* * if w is a child of this panel and the only widget in a cell the cell * will be removed */ w.removeFromParent(); if (newCell) { insertCell(m_cellMap.size()); } addWidgetTo(w, m_cellMap.size() - 1); }
From source file:asquare.gwt.tk.client.ui.ExposedCellPanel.java
License:Apache License
/** * Inserts a new cell at the specified index and appends the widget to the * cell./* w ww .j ava 2 s . c om*/ * * @param w a widget * @param cellIndex the index of the cell * @throws IndexOutOfBoundsException if <code>cellIndex</code> is less * than 0 or greater than the number of cells */ public void insert(Widget w, int cellIndex) { /* * if w is a child of this panel and the only widget in a cell the cell * will be removed */ w.removeFromParent(); insertCell(cellIndex); insertWidgetAt(w, cellIndex, 0); }
From source file:asquare.gwt.tk.client.ui.ExposedCellPanel.java
License:Apache License
/** * Inserts a widget into a an existing cell. Any widgets with indexes * greater than or equal to <code>wIndex</code> will be shifted over. * /*from ww w . j ava 2 s .c o m*/ * @param w a widget * @param cellIndex the index of the cell * @param wIndex the index of the widget before which <code>w</code> will * be inserted * @throws IndexOutOfBoundsException if the cell specified by * <code>cellIndex</code> does not exist * @throws IndexOutOfBoundsException if <code>wIndex</code> is less than 0 * or greater than the number of widgets in the specified cell */ public void insertWidgetAt(Widget w, int cellIndex, int wIndex) { /* * The cell will be removed if w is a child of this panel and w is the * only widget in the cell */ w.removeFromParent(); GwtUtil.rangeCheck(m_cellMap, cellIndex, false); List<Widget> cellWidgets = m_cellMap.get(cellIndex); if (cellWidgets == null) { if (wIndex != 0) throw new IndexOutOfBoundsException(Integer.toString(wIndex)); cellWidgets = new ArrayList<Widget>(); m_cellMap.set(cellIndex, cellWidgets); // pre: cellIndex has been inserted } GwtUtil.rangeCheck(cellWidgets, wIndex, true); cellWidgets.add(wIndex, w); Element td = getCellElement(cellIndex); insert(w, td, wIndex, true); }
From source file:ca.upei.ic.timetable.client.CalendarPanel.java
License:Apache License
protected void itemDidRemove(Calendar calendar, CalendarItem item) { for (Widget w : itemWidgets_.get(item)) { w.removeFromParent(); }/*from w w w . ja v a 2s. com*/ itemWidgets_.remove(item); // reorganize all panels for (int i = 0; i < panel_.getWidgetCount(); i++) { AbsolutePanel panel = (AbsolutePanel) panel_.getWidget(i); reorganizePanel(panel); } }
From source file:cc.kune.core.client.dnd.FolderContainerDropController.java
License:GNU Affero Public License
/** * Move./* ww w . ja v a2s . c o m*/ * * @param widget * the widget * @param destToken * the dest token */ private void move(final Widget widget, final StateToken destToken) { widget.removeFromParent(); final StateToken tokenToMove = ((FolderItemWidget) widget).getToken(); contentService.moveContent(session.getUserHash(), tokenToMove, destToken, new AsyncCallback<StateContainerDTO>() { @Override public void onFailure(final Throwable caught) { erroHandler.process(caught); stateManager.refreshCurrentState(); NotifyUser.hideProgress(); } @Override public void onSuccess(final StateContainerDTO result) { NotifyUser.hideProgress(); contentCache.remove(tokenToMove); contentCache.remove(destToken); } }); }
From source file:ch.unifr.pai.mindmap.client.mindmap.MindMapCanvas.java
License:Apache License
/** * The set up for the canvas with its base structure and the registration of the drop handler for the trash bin *///from w w w. j av a 2 s.c o m public MindMapCanvas() { super(); initWidget(panel); toolbar = new Toolbar(this); bgimg.getElement().getStyle().setProperty("maxHeight", "100%"); bgimg.getElement().getStyle().setProperty("maxWidth", "100%"); SimplePanel bgpanel = new SimplePanel(); bgpanel.getElement().getStyle().setProperty("textAlign", "center"); canvas.getElement().setId("mindmapCanvas"); canvas.getElement().getStyle().setPosition(Position.ABSOLUTE); canvas.getElement().getStyle().setTop(0, Unit.PX); canvas.getElement().getStyle().setLeft(0, Unit.PX); canvas.getElement().getStyle().setRight(0, Unit.PX); canvas.getElement().getStyle().setBottom(0, Unit.PX); bgpanel.getElement().getStyle().setPosition(Position.ABSOLUTE); bgpanel.getElement().getStyle().setTop(0, Unit.PX); bgpanel.getElement().getStyle().setLeft(0, Unit.PX); bgpanel.getElement().getStyle().setRight(0, Unit.PX); bgpanel.getElement().getStyle().setBottom(0, Unit.PX); bgpanel.setWidget(bgimg); toolbar.getElement().getStyle().setPosition(Position.ABSOLUTE); toolbar.getElement().getStyle().setLeft(0, Unit.PX); toolbar.getElement().getStyle().setRight(0, Unit.PX); toolbar.getElement().getStyle().setBottom(0, Unit.PX); panel.add(bgpanel); panel.add(canvas); panel.add(toolbar); panel.add(trashBin); DragNDrop.setDropHandler(trashBin, new DropTargetHandler() { @Override public void onHoverEnd(String deviceId, Widget widget, Element dragProxy, Event event) { trashBin.setUrl(GWT.getModuleBaseURL() + "images/trashbin.png"); } @Override public void onHover(String deviceId, Widget widget, Element dragProxy, Event event, Double intersectionPercentage, Double intersectionPercentageWithTarget) { trashBin.setUrl(GWT.getModuleBaseURL() + "images/trashbinhover.png"); } @Override public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event, Double intersectionPercentage, Double intersectionPercentageWithTarget) { removeNoteWidget(widget); widget.removeFromParent(); return false; } @Override public Priority getPriority() { return Priority.NORMAL; } }, true); trashBin.getElement().getStyle().setPosition(Position.ABSOLUTE); trashBin.getElement().getStyle().setRight(0, Unit.PX); trashBin.getElement().getStyle().setBottom(00, Unit.PX); getElement().getStyle().setOverflow(Overflow.VISIBLE); canvas.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { String deviceId = MultiCursorController.getUUID(event.getNativeEvent()); String selected = selectedElements.get(deviceId); if (selectedElements.get(deviceId) != null) { eventBus.fireEvent(UpdateMindmapNoteEvent.block(selected, false)); } } }); }
From source file:com.ait.ext4j.client.core.WidgetComponent.java
License:Apache License
public WidgetComponent(Widget widget) { this.componentId = hiddenDivID + "_" + generateId(); this.w = widget; init();/*from www . ja va 2 s . com*/ createHiddenDiv(); setId(DomUtil.getID(widget)); addListener("beforedestroy", new Function() { public void execute() { Widget widget = (Widget) JsoHelper.getAttributeAsObject(config, "widget"); if (DOM.getParent(widget.getElement()) != null) { widget.removeFromParent(); } } }); }
From source file:com.ait.lienzo.ks.client.ui.components.KSContainer.java
License:Open Source License
@Override public boolean remove(Widget w) { if (w instanceof Component) { super.remove((Component) w, false); } else {/* w w w . j ava2 s . c o m*/ w.removeFromParent(); } return true; }
From source file:com.ait.toolkit.sencha.touch.client.core.ComplexContainer.java
License:Open Source License
/** * Add a widget to the Container./*from w w w . j a v a2 s .c o m*/ * * @param widget * the widget to add */ @Override public void add(Widget widget) { // Physical Dettach widget.removeFromParent(); if (widget instanceof Component) { // Logical attach. getChildren().add(widget); // Physical Attach add((Component) widget); // Adopt widget // adopt(widget); } else { // We must be in the presence of GWT Widgets. String id = DomUtil.getID(widget); if (id == null) { id = Ext.generateId(); DomUtil.setID(widget, id); } JavaScriptObject compJS = getComponentJS(id); WidgetComponent component = null; if (compJS != null) { component = new WidgetComponent(compJS); component.setVisible(true); } else { component = new WidgetComponent(widget); } component.setParentWidget(this); // Logical attach. getChildren().add(widget); // Physical Attach add(component); // Adopt widget // adopt(widget); } }
From source file:com.ait.toolkit.sencha.touch.client.core.ComplexContainer.java
License:Open Source License
/** * Insert a new child Widget into this Panel at a specified index, attaching * its Element to the specified container Element. The child Element will * either be attached to the container at the same index, or simply appended * to the container, depending on the value of <code>domInsert</code>. * /* w w w. j a v a 2 s . c om*/ * @param child * the child Widget to be added * @param container * the Element within which <code>child</code> will be contained * @param beforeIndex * the index before which <code>child</code> will be inserted * @param domInsert * if <code>true</code>, insert <code>child</code> into * <code>container</code> at <code>beforeIndex</code>; otherwise * append <code>child</code> to the end of <code>container</code> * . */ protected void insert(Widget child, Element container, int beforeIndex, boolean domInsert) { // Validate index; adjust if the widget is already a child of this // panel. beforeIndex = adjustIndex(child, beforeIndex); // Detach new child. child.removeFromParent(); // Logical attach. getChildren().insert(child, beforeIndex); // Physical attach. if (domInsert) { DOM.insertChild(container, child.getElement(), beforeIndex); } else { DOM.appendChild(container, child.getElement()); } // Adopt. adopt(child); }