List of usage examples for com.google.gwt.user.client.ui Widget isAttached
@Override public boolean isAttached()
From source file:com.seanchenxi.gwt.ui.widget.Mask.java
License:Apache License
public static void showMaskFor(final Widget widget) { clearHandler();// w ww . ja v a 2 s . c o m if (widget.isAttached()) { RESOURCES.style().ensureInjected(); MASK.addStyleName(RESOURCES.style().loaderIcon()); Element element = widget.getElement(); MASK.setPixelSize(element.getOffsetWidth(), element.getOffsetHeight()); RootPanel.get().add(MASK, DOM.getAbsoluteLeft(element), DOM.getAbsoluteTop(element)); } else { delayHandler(widget); } }
From source file:com.sencha.gxt.core.client.util.ClickRepeater.java
License:sencha.com license
/** * Creates a new click repeater./*from w w w . java 2s . co m*/ * * @param target the target widget * @param el the element to be clicked */ public ClickRepeater(Widget target, XElement el) { this.target = target; this.el = el; preview = new BaseEventPreview() { protected boolean onPreview(NativePreviewEvent pe) { if (pe.getTypeInt() == Event.ONMOUSEUP) { ClickRepeater.this.handleMouseUp(); } return true; } }; preview.setAutoHide(false); target.addDomHandler(handler, MouseDownEvent.getType()); target.addDomHandler(handler, MouseOutEvent.getType()); target.addDomHandler(handler, MouseOverEvent.getType()); if (GXT.isTouch()) { target.addDomHandler(handler, TouchStartEvent.getType()); target.addDomHandler(handler, TouchEndEvent.getType()); } target.addAttachHandler(handler); if (target.isAttached()) { doAttach(); } }
From source file:com.sencha.gxt.widget.core.client.form.error.SideErrorHandler.java
License:sencha.com license
public SideErrorHandler(Widget target) { this.target = target; Handler handler = new Handler(); handlers.add(target.addAttachHandler(handler)); if (target.isAttached()) { doAttach();/* w ww . j a v a 2s. co m*/ } if (target instanceof HasResizeHandlers) { handlers.add(((HasResizeHandlers) target).addResizeHandler(handler)); } resources = GWT.create(SideErrorResources.class); }
From source file:com.sencha.gxt.widget.core.client.grid.editing.GridInlineEditing.java
License:sencha.com license
private void removeEditor(final GridCell cell, final IsField<?> field) { assert field != null; removeFieldBlurHandler();/* w w w. j a va 2 s . co m*/ if (GXT.isIE() && field instanceof ValueBaseField<?>) { ValueBaseField<?> f = (ValueBaseField<?>) field; f.getCell().getInputElement(f.getElement()).blur(); } Widget w = field.asWidget(); if (field != null && w.isAttached()) { field.asWidget().setVisible(false); ComponentHelper.setParent(null, w); ComponentHelper.doDetach(w); } }
From source file:com.totsp.gwittir.client.ui.util.ChangeMarkerListener.java
License:Open Source License
public void propertyChange(PropertyChangeEvent propertyChangeEvent) { if (propertyChangeEvent.getSource() instanceof Widget) { Widget widget = (Widget) propertyChangeEvent.getSource(); if (propertyChangeEvent.getPropertyName().equals("value")) { valueHasChanged = true;//from w w w . j ava 2 s .co m if (factory.isMarking() && widget.isAttached()) { showMarker(widget); } if (widget instanceof BoundWidget) { BoundWidget bw = (BoundWidget) widget; List widgets = (List) factory.widgetLookup.get(bw.getModel()); if (widgets == null) { widgets = new ArrayList(); factory.widgetLookup.put(bw.getModel(), widgets); } if (!widgets.contains(bw)) { widgets.add(bw); } } } else if (propertyChangeEvent.getPropertyName().equals("attached")) { Boolean att = (Boolean) propertyChangeEvent.getNewValue(); if (factory.isMarking() && att.booleanValue() && valueHasChanged) { showMarker(widget); } else { hideMarker(widget); } } } }
From source file:com.vaadin.client.ui.customlayout.CustomLayoutConnector.java
License:Apache License
@Override public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) { // Must call here in addition to onStateChanged because // onConnectorHierarchyChange is invoked before onStateChanged updateHtmlTemplate();//from ww w.j av a 2s .c o m // For all contained widgets for (ComponentConnector child : getChildComponents()) { String location = getState().childLocations.get(child); try { getWidget().setWidget(child.getWidget(), location); } catch (final IllegalArgumentException e) { // If no location is found, this component is not visible getLogger().warning("Child not rendered as no slot with id '" + location + "' has been defined"); } } for (ComponentConnector oldChild : event.getOldChildren()) { if (oldChild.getParent() == this) { // Connector still a child of this continue; } Widget oldChildWidget = oldChild.getWidget(); if (oldChildWidget.isAttached()) { // slot of this widget is emptied, remove it getWidget().remove(oldChildWidget); } } }
From source file:com.vaadin.client.ui.tabsheet.TabsheetBaseConnector.java
License:Apache License
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { super.onStateChanged(stateChangeEvent); // Update member references getWidget().setEnabled(isEnabled()); // Widgets in the TabSheet before update ArrayList<Widget> oldWidgets = new ArrayList<Widget>(); for (Iterator<Widget> iterator = getWidget().getWidgetIterator(); iterator.hasNext();) { oldWidgets.add(iterator.next()); }/*from ww w . j a v a 2s.c o m*/ // Clear previous values getWidget().clearTabKeys(); int index = 0; for (TabState tab : getState().tabs) { final String key = tab.key; final boolean selected = key.equals(getState().selected); getWidget().addTabKey(key, !tab.enabled && tab.visible); if (selected) { getWidget().setActiveTabIndex(index); } getWidget().renderTab(tab, index); if (selected) { getWidget().selectTab(index); } index++; } int tabCount = getWidget().getTabCount(); while (tabCount-- > index) { getWidget().removeTab(index); } for (int i = 0; i < getWidget().getTabCount(); i++) { ComponentConnector p = getWidget().getTab(i); // null for PlaceHolder widgets if (p != null) { oldWidgets.remove(p.getWidget()); } } // Detach any old tab widget, should be max 1 for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator.hasNext();) { Widget oldWidget = iterator.next(); if (oldWidget.isAttached()) { oldWidget.removeFromParent(); } } }
From source file:com.vaadin.client.WidgetUtil.java
License:Apache License
/** * Kind of stronger version of isAttached(). In addition to std isAttached, * this method checks that this widget nor any of its parents is hidden. Can * be e.g used to check whether component should react to some events or * not./*from ww w .j av a 2s . c om*/ * * @param widget * @return true if attached and displayed */ public static boolean isAttachedAndDisplayed(Widget widget) { if (widget.isAttached()) { /* * Failfast using offset size, then by iterating the widget tree */ boolean notZeroSized = widget.getOffsetHeight() > 0 || widget.getOffsetWidth() > 0; return notZeroSized || checkVisibilityRecursively(widget); } else { return false; } }
From source file:com.vaadin.terminal.gwt.client.ApplicationConnection.java
License:Open Source License
private void purgeUnregistryBag() { for (String id : unregistryBag) { ComponentDetail componentDetail = idToPaintableDetail.get(id); if (componentDetail == null) { /*/* w w w . ja v a2 s .c o m*/ * this should never happen, but it does :-( See e.g. * com.vaadin.tests.components.accordion.RemoveTabs (with test * script) */ VConsole.error("ApplicationConnetion tried to unregister component (id=" + id + ") that is never registered (or already unregistered)"); continue; } // check if can be cleaned Widget component = (Widget) componentDetail.getComponent(); if (!component.isAttached()) { // clean reference from ac to paintable idToPaintableDetail.remove(id); } /* * else NOP : same component has been reattached to another parent * or replaced by another component implementation. */ } unregistryBag.clear(); }
From source file:com.vaadin.terminal.gwt.client.ui.VCustomLayout.java
License:Open Source License
/** Update the layout from UIDL */ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { this.client = client; // ApplicationConnection manages generic component features if (client.updateComponent(this, uidl, true)) { return;/*from w w w.ja va2 s .c o m*/ } pid = uidl.getId(); if (!hasTemplate()) { // Update HTML template only once initializeHTML(uidl, client); } // Evaluate scripts eval(scripts); scripts = null; iLayout(); // TODO Check if this is needed client.runDescendentsLayout(this); Set<Widget> oldWidgets = new HashSet<Widget>(); oldWidgets.addAll(locationToWidget.values()); // For all contained widgets for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) { final UIDL uidlForChild = (UIDL) i.next(); if (uidlForChild.getTag().equals("location")) { final String location = uidlForChild.getStringAttribute("name"); final Paintable child = client.getPaintable(uidlForChild.getChildUIDL(0)); try { setWidget((Widget) child, location); child.updateFromUIDL(uidlForChild.getChildUIDL(0), client); } catch (final IllegalArgumentException e) { // If no location is found, this component is not visible } oldWidgets.remove(child); } } for (Iterator<Widget> iterator = oldWidgets.iterator(); iterator.hasNext();) { Widget oldWidget = iterator.next(); if (oldWidget.isAttached()) { // slot of this widget is emptied, remove it remove(oldWidget); } } iLayout(); // TODO Check if this is needed client.runDescendentsLayout(this); }