List of usage examples for com.google.gwt.user.client.ui Widget isAttached
@Override public boolean isAttached()
From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
public static void resizeUsingInfo(int containerHeight, int containerWidth, Iterator<Widget> widgets, int parentAdjustHeight, int parentAdjustWidth) { while (widgets.hasNext()) { Widget widget = widgets.next();//from w w w .java 2 s. co m if (widget == null || !widget.isVisible()) { continue; } int availableHeight = containerHeight; int availableWidth = containerWidth; if (widget instanceof HasLayoutInfo) { String name = widget.getClass().getName(); if (debug) { GWT.log(CommonUtils.formatJ("%s: ", CommonUtils.simpleClassName(widget.getClass())), null); } LayoutInfo info = ((HasLayoutInfo) widget).getLayoutInfo(); info.beforeLayout(); if (info.to100percentOfAvailableHeight() || info.to100percentOfAvailableWidth()) { int usedHeight = 0; int usedWidth = 0; Widget parent = widget.getParent(); Iterator<Widget> childIterator = null; availableHeight = info.useBestOffsetForParentHeight() ? getBestOffsetHeight(parent.getElement(), true) : containerHeight; availableHeight = Math.min(availableHeight, containerHeight); availableWidth = info.useBestOffsetForParentWidth() ? getBestOffsetWidth(parent.getElement(), true) : containerWidth; availableWidth = Math.min(availableWidth, containerWidth); if (parent instanceof HasLayoutInfo) { childIterator = ((HasLayoutInfo) parent).getLayoutInfo().getLayoutWidgets(); } else if (parent instanceof HasWidgets) { childIterator = ((HasWidgets) parent).iterator(); } boolean ignoreChildrenForHeight = info.to100percentOfAvailableHeight() && (isDirectionalLayoutPanel(parent, true) || info.ignoreSiblingsForHeight()); boolean ignoreChildrenForWidth = info.to100percentOfAvailableWidth() && (isDirectionalLayoutPanel(parent, false) || info.ignoreSiblingsForWidth()); if (childIterator != null) { while (childIterator.hasNext()) { Widget cw = childIterator.next(); if (cw != widget && WidgetUtils.isVisibleWithOffsetParent(cw.getElement()) && cw.isAttached()) { if (!ignoreChildrenForHeight) { usedHeight += getBestOffsetHeight(cw.getElement(), true, false); } if (!ignoreChildrenForWidth) { usedWidth += getBestOffsetWidth(cw.getElement()); } } } } if (info.to100percentOfAvailableHeight()) { availableHeight = availableHeight - usedHeight - parentAdjustHeight - info.getAdjustHeight(); if (debug) { GWT.log(CommonUtils.formatJ("%s: %s - comp %s", CommonUtils.simpleClassName(widget.getClass()), availableHeight, containerHeight), null); } if (availableHeight >= 0) { widget.setHeight((availableHeight) + "px"); } } if (info.to100percentOfAvailableWidth()) { availableWidth = availableWidth - usedWidth - parentAdjustWidth - info.getAdjustWidth(); if (availableWidth >= 0) { widget.setWidth((availableWidth) + "px"); } } } Iterator<Widget> toResize = info.getWidgetsToResize(); while (toResize.hasNext()) { toResize.next().setHeight(containerHeight + "px"); } resizeUsingInfo(availableHeight, availableWidth, info.getLayoutWidgets(), info.getClientAdjustHeight(), info.getClientAdjustWidth()); info.afterLayout(); } // haslayoutinfo else if (widget instanceof HasWidgets) { resizeUsingInfo(availableHeight, availableWidth, ((HasWidgets) widget).iterator(), 0, 0); } } // while }
From source file:cc.kune.common.client.tooltip.Tooltip.java
License:GNU Affero Public License
public void show(final Widget forWidget, final String text) { if (current != null && !current.equals(forWidget) && getTip().isShowing()) { Tooltip.getTip().hide();// www .j av a 2 s.c om } setText(text); if (forWidget.isAttached() && forWidget.isVisible() && (TextUtils.notEmpty(text) && !"undefined".equals(text))) { Tooltip.super.show(); current = forWidget; final int clientWidth = Window.getClientWidth(); if (mainPanel.getOffsetWidth() >= clientWidth) { mainPanel.getElement().getStyle().setWidth(clientWidth - 20, Unit.PX); } else if (mainPanel.getOffsetWidth() > 430) { mainPanel.getElement().getStyle().setWidth(430, Unit.PX); } else { mainPanel.getElement().getStyle().clearWidth(); } showAt(forWidget); } }
From source file:cc.kune.core.client.dnd.AbstractDropController.java
License:GNU Affero Public License
@Override public void init(final Widget dropTarget) { dropController = new SimpleDropController(dropTarget) { @Override/*from w w w . j a v a2s . co m*/ public void onDrop(final DragContext context) { boolean droppedSomething = false; super.onDrop(context); for (final Widget widget : context.selectedWidgets) { if (acceptedTypes.contains(widget.getClass())) { onDropAllowed(widget, this); droppedSomething = true; } } if (droppedSomething) { onGroupDropFinished(this); } } @Override public void onEnter(final DragContext context) { super.onEnter(context); for (final Widget widget : context.selectedWidgets) { if (acceptedTypes.contains(widget.getClass())) { onEnterAllowed(this); } } } @Override public void onLeave(final DragContext context) { super.onLeave(context); for (final Widget widget : context.selectedWidgets) { if (acceptedTypes.contains(widget.getClass())) { onLeaveAllowed(this); } } } @Override public void onPreviewDrop(final DragContext context) throws VetoDragException { for (final Widget widget : context.selectedWidgets) { if (acceptedTypes.contains(widget.getClass())) { onPreviewAllowed(widget, this); } else { throw new VetoDragException(); } } super.onPreviewDrop(context); } }; dropTarget.addStyleName("k-drop-allowed"); if (dropTarget.isAttached()) { dragController.registerDropController(dropController); } dropTarget.addAttachHandler(new Handler() { @Override public void onAttachOrDetach(final AttachEvent event) { if (!event.isAttached()) { dragController.unregisterDropController(dropController); } else { dragController.registerDropController(dropController); } } }); }
From source file:co.fxl.gui.gwt.GWTElement.java
License:Open Source License
@SuppressWarnings("unchecked") protected R focus(final boolean focus, Widget widget) { if (widget.isVisible() && widget.isAttached()) { Focusable focusable = (Focusable) widget; focusable.setFocus(focus);/* w w w. j a v a 2s.co m*/ notifyFocusListeners(focus); } return (R) this; }
From source file:com.cgxlib.xq.client.plugins.widgets.WidgetsUtils.java
License:Apache License
private static void replaceWidget(Widget oldWidget, Widget newWidget, boolean remove) { Widget parent = oldWidget.getParent(); boolean removed = false; // TODO: handle tables if (parent instanceof HTMLPanel) { ((HTMLPanel) parent).addAndReplaceElement(newWidget, (Element) oldWidget.getElement()); if (!remove) { $(newWidget).before($(oldWidget)); }//from w w w . ja v a 2 s. c o m removed = true; } else if (parent instanceof ComplexPanel) { ((ComplexPanel) parent).add(newWidget); } else if (parent instanceof SimplePanel) { ((SimplePanel) parent).setWidget(newWidget); } else if (parent instanceof Panel) { ((Panel) parent).add(newWidget); } else { assert false : "Can not replace an attached widget whose parent is a " + parent.getClass().getName(); } if (remove && !removed && oldWidget.isAttached()) { oldWidget.removeFromParent(); } else { oldWidget.setVisible(false); } }
From source file:com.epam.feel.client.ui.util.gwtupload.FixedSingleUploader.java
License:Apache License
/** * This constructor allows to use an existing form panel. * /*from w w w. j a va2s . co m*/ * @param type * file input to use * @param status * Customized status widget to use * @param submitButton * Customized button which submits the form * @param form * Customized form panel */ public FixedSingleUploader(FileInputType type, IUploadStatus status, Widget submitButton, FormPanel form) { super(type, form); final FixedUploader thisInstance = this; if (status == null) { status = new BaseUploadStatus(); super.add(status.getWidget()); } super.setStatusWidget(status); this.button = submitButton; if (submitButton != null) { submitButton.addStyleName("submit"); if (submitButton instanceof HasClickHandlers) { ((HasClickHandlers) submitButton).addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { thisInstance.submit(); } }); } if (submitButton instanceof HasText) { ((HasText) submitButton).setText(I18N_CONSTANTS.uploaderSend()); } // The user could have attached the button anywhere in the page. if (!submitButton.isAttached()) { super.add(submitButton); } } }
From source file:com.ephesoft.gxt.rv.client.view.batch.DLFView.java
License:Open Source License
@Override public void focus() { if (widget instanceof Widget) { final Widget inputWidget = (Widget) (widget); if (inputWidget.isAttached()) { setFocus();//from www . j a va 2s. c o m } else { Timer timer = new Timer() { @Override public void run() { if (inputWidget.isAttached()) { cancel(); setFocus(); } } }; timer.scheduleRepeating(20); } } }
From source file:com.extjs.gxt.ui.client.widget.ComponentHelper.java
License:sencha.com license
public static void doAttach(Widget widget) { if (widget != null && !widget.isAttached()) { doAttachNative(widget);// w ww .j a v a 2s.c om } }
From source file:com.extjs.gxt.ui.client.widget.ComponentHelper.java
License:sencha.com license
public static void doDetach(Widget widget) { if (widget != null && widget.isAttached()) { doDetachNative(widget);/*from w ww. j a v a2 s . c o m*/ } }
From source file:com.gwtext.client.widgets.map.Marker.java
License:Open Source License
/** * Sets the info bubble to be a Widget. Only supported by GoogleMaps. For other map providers use * {@link #setInfoBubble(String)}./*w w w . j a v a 2 s. co m*/ * * @param widget the widget to add to the info bubble. */ public void setInfoBubble(Widget widget) { if (widget instanceof Component) { Component component = (Component) widget; if (!component.isRendered()) { WidgetComponent.createHiddenDiv(); component.render(WidgetComponent.hiddenDivID); } } else { if (!widget.isAttached()) { WidgetComponent.createHiddenDiv(); RootPanel.get(WidgetComponent.hiddenDivID).add(widget); } } setInfoBubble(widget.getElement()); }