List of usage examples for com.google.gwt.user.client.ui Widget isVisible
@Override
public boolean isVisible()
From source file:burrito.client.widgets.form.EditForm.java
License:Apache License
public void add(Widget widget, String label, String description) { if (widget instanceof HasValidators) { validateables.add((HasValidators) widget); }/*from w ww. j ava2s .c o m*/ if (widget instanceof HasKeyDownHandlers) { ((HasKeyDownHandlers) widget).addKeyDownHandler(saveEnablerKeyDownAction); } if (widget instanceof HasChangeHandlers) { ((HasChangeHandlers) widget).addChangeHandler(saveEnablerChangeHandler); } if (widget instanceof CheckBox) { ((CheckBox) widget).addClickHandler(saveEnablerClickHandler); } List<Widget> companionWidgets = new ArrayList<Widget>(); if (label == null) { label = ""; } Label l = new Label(label); l.addStyleName("k5-EditForm-label"); if (!widget.isVisible()) l.setVisible(false); main.getFlexCellFormatter().setRowSpan(this.currentRow, 0, 2); main.setWidget(this.currentRow, 0, l); companionWidgets.add(l); main.setWidget(this.currentRow, 1, widget); widget.addStyleName("cell-widget-inner"); main.getCellFormatter().addStyleName(this.currentRow, 1, "cell-widget"); main.getCellFormatter().addStyleName(this.currentRow, 0, "cell-label"); if (description == null) { description = ""; } this.currentRow++; Label desc = new Label(description); desc.addStyleName("k5-EditForm-description"); if (!widget.isVisible()) desc.setVisible(false); main.setWidget(this.currentRow, 0, desc); main.getCellFormatter().addStyleName(this.currentRow, 0, "cell-description"); companionWidgets.add(desc); this.currentRow++; VerticalSpacer spacer = new VerticalSpacer(10); main.setWidget(this.currentRow, 0, spacer); companionWidgets.add(spacer); this.currentRow++; companionWidgetsMap.put(widget, companionWidgets); }
From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
public static void maximiseWidget(Widget widget) { restoreFromMaximise();/*from w ww . j a va 2 s . c o m*/ hiddenWidgets = new ArrayList<Widget>(); morphedWidgets = new ArrayList<SplitLayoutPanel>(); elementLayouts = new ArrayList<ElementLayout>(); Element e = widget.getElement(); while (widget.getParent() != null) { Widget parent = widget.getParent(); if (parent instanceof SplitLayoutPanel) { morphSplitPanel((SplitLayoutPanel) parent, widget, false); } else if (parent instanceof HasWidgets && !(parent instanceof TabPanel)) { HasWidgets hw = (HasWidgets) parent; for (Iterator<Widget> itr = hw.iterator(); itr.hasNext();) { Widget w = itr.next(); if (w != widget && w.isVisible()) { hiddenWidgets.add(w); w.setVisible(false); } } } widget = widget.getParent(); } while (e.getParentElement() != RootPanel.get().getElement()) { ElementLayout layout = new ElementLayout(e); elementLayouts.add(layout); layout.maximise(); e = e.getParentElement(); } }
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(); if (widget == null || !widget.isVisible()) { continue; }/*from w ww. j a v a2 s.c om*/ 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();/*from w w w. ja v a2s .co m*/ } 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: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 2 s.co m*/ notifyFocusListeners(focus); } return (R) this; }
From source file:com.extjs.gxt.ui.client.widget.Component.java
License:sencha.com license
/** * Returns <code>true</code> if the component is visible. * /* w w w .j a va 2 s . co m*/ * @param deep true to search up the component hierarchy */ public boolean isVisible(boolean deep) { Widget w = getParent(); if (deep && w != null) { if (w instanceof Component) { Component c = (Component) w; return rendered && !hidden && el().isVisible(false) && c.isVisible(deep); } else { return rendered && !hidden && w.isVisible() && el().isVisible(deep); } } else { return rendered && !hidden && el().isVisible(deep); } }
From source file:com.google.livingstories.client.ui.PartialDisclosurePanel.java
License:Apache License
private void setContentDisplay(boolean animate) { if (isOpen) { removeStyleDependentName(STYLENAME_SUFFIX_CLOSED); addStyleDependentName(STYLENAME_SUFFIX_OPEN); } else {//from www .j a v a2 s .c om removeStyleDependentName(STYLENAME_SUFFIX_OPEN); addStyleDependentName(STYLENAME_SUFFIX_CLOSED); } if (getContent() != null) { int oldHeight = getContent().getElement().getClientHeight(); DOM.setStyleAttribute(contentWrapper.getElement(), "height", oldHeight + "px"); for (Widget widget : toggledWidgets) { widget.setVisible(!widget.isVisible()); } int newHeight = getContent().getElement().getClientHeight(); if (animate) { ExpandEffect animation = new ExpandEffect(contentWrapper, newHeight); animation.run(Constants.ANIMATION_DURATION); } else { DOM.setStyleAttribute(contentWrapper.getElement(), "height", "auto"); runCompletionCode(); } } }
From source file:com.googlecode.kanbanik.client.components.WindowBox.java
License:Apache License
/** * Called when the minimize icon is clicked. The default implementation hides the container of the dialog box. * * @param event The {@link ClickEvent} to handle *///ww w . j a v a 2s .c om protected void onMinimizeClick(ClickEvent event) { Widget widget = getWidget(); if (widget == null) return; boolean visible = widget.isVisible(); int offsetWidth = widget.getOffsetWidth(); widget.setVisible(!visible); this.minimized = visible; if (visible) { this.container.setWidth(offsetWidth + "px"); this.minimize.setStyleName("gwt-extras-dialog-maximize"); } else { this.container.setWidth(null); this.minimize.setStyleName("gwt-extras-dialog-minimize"); } }
From source file:com.sencha.gxt.widget.core.client.Component.java
License:sencha.com license
/** * Returns <code>true</code> if the widget is visible. * * @param deep true to search up the widget hierarchy * @return true if the widget is visible *///from w w w .j a v a 2s. co m public boolean isVisible(boolean deep) { Widget w = getParent(); if (deep && w != null) { if (w instanceof Component) { Component c = (Component) w; return isAttached() && !hidden && getElement().isVisible(false) && c.isVisible(deep); } else { return isAttached() && !hidden && w.isVisible() && getElement().isVisible(deep); } } else { return isAttached() && !hidden && getElement().isVisible(deep); } }
From source file:com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.java
License:sencha.com license
@Override protected void doLayout() { Size size = getElement().getStyleSize(); if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest(getId() + " doLayout size: " + size); }// ww w .j av a 2s .c o m if ((size.getHeight() == 0 && size.getWidth() == 0) || size.getWidth() == 0) { return; } int w = size.getWidth() - getScrollOffset(); int h = size.getHeight(); int styleHeight = Util.parseInt(getElement().getStyle().getProperty("height"), Style.DEFAULT); int styleWidth = Util.parseInt(getElement().getStyle().getProperty("width"), Style.DEFAULT); boolean findWidth = styleWidth == -1; boolean findHeight = styleHeight == -1; if (GXTLogConfiguration.loggingIsEnabled()) { logger.finest(getId() + " findWidth: " + findWidth + " findHeight: " + findHeight); } int calculateWidth = 0; int maxWidgetHeight = 0; int maxMarginTop = 0; int maxMarginBottom = 0; for (int i = 0, len = getWidgetCount(); i < len; i++) { Widget widget = getWidget(i); BoxLayoutData layoutData = null; Object d = widget.getLayoutData(); if (d instanceof BoxLayoutData) { layoutData = (BoxLayoutData) d; } else { layoutData = new BoxLayoutData(); widget.setLayoutData(layoutData); } Margins cm = layoutData.getMargins(); if (cm == null) { cm = new Margins(0); layoutData.setMargins(cm); } } if (findWidth || findHeight) { for (int i = 0, len = getWidgetCount(); i < len; i++) { Widget widget = getWidget(i); if (!widget.isVisible()) { continue; } BoxLayoutData layoutData = (BoxLayoutData) widget.getLayoutData(); Margins cm = layoutData.getMargins(); calculateWidth += widget.getOffsetWidth(); maxWidgetHeight = Math.max(maxWidgetHeight, widget.getOffsetHeight()); calculateWidth += (cm.getLeft() + cm.getRight()); maxMarginTop = Math.max(maxMarginTop, cm.getTop()); maxMarginBottom = Math.max(maxMarginBottom, cm.getBottom()); } maxWidgetHeight += (maxMarginTop + maxMarginBottom); if (findWidth) { w = calculateWidth; } if (findHeight) { h = maxWidgetHeight; } } int pl = 0; int pt = 0; int pb = 0; int pr = 0; if (getPadding() != null) { pl = getPadding().getLeft(); pt = getPadding().getTop(); pb = getPadding().getBottom(); pr = getPadding().getRight(); } if (findHeight) { h += pt + pb; } if (findWidth) { w += pl + pr; } int stretchHeight = h - pt - pb; int totalFlex = 0; int totalWidth = 0; int maxHeight = 0; for (int i = 0, len = getWidgetCount(); i < len; i++) { Widget widget = getWidget(i); widget.addStyleName(CommonStyles.get().positionable()); widget.getElement().getStyle().setMargin(0, Unit.PX); if (!widget.isVisible()) { continue; } if (widget == more) { triggerWidth = widget.getOffsetWidth() + 10; } BoxLayoutData layoutData = (BoxLayoutData) widget.getLayoutData(); Margins cm = layoutData.getMargins(); // TODO strange issue where getOffsetWidth call in 2nd loop is returning smaller number than actual offset // when packing CENTER or END so we cache the offsetWidth for use in 2nd loop // with buttons, the button is word wrapping causing the button to be narrower and taller int ww = widget.getOffsetWidth(); loopWidthMap.put(widget, ww); loopHeightMap.put(widget, widget.getOffsetHeight()); totalFlex += layoutData.getFlex(); totalWidth += (ww + cm.getLeft() + cm.getRight()); maxHeight = Math.max(maxHeight, widget.getOffsetHeight() + cm.getTop() + cm.getBottom()); } int innerCtHeight = maxHeight + pt + pb; if (hBoxLayoutAlign.equals(HBoxLayoutAlign.STRETCH)) { getContainerTarget().setSize(w, h, true); } else if (hBoxLayoutAlign.equals(HBoxLayoutAlign.MIDDLE) || hBoxLayoutAlign.equals(HBoxLayoutAlign.BOTTOM)) { getContainerTarget().setSize(w, h = Math.max(h, innerCtHeight), true); } else { getContainerTarget().setSize(w, innerCtHeight, true); } int extraWidth = w - totalWidth - pl - pr; int allocated = 0; int componentWidth, componentHeight, componentTop; int availableHeight = h - pt - pb; if (getPack().equals(BoxLayoutPack.CENTER)) { pl += extraWidth / 2; } else if (getPack().equals(BoxLayoutPack.END)) { pl += extraWidth; } for (int i = 0, len = getWidgetCount(); i < len; i++) { Widget widget = getWidget(i); if (!widget.isVisible()) { continue; } BoxLayoutData layoutData = (BoxLayoutData) widget.getLayoutData(); Margins cm = layoutData.getMargins(); componentWidth = loopWidthMap.remove(widget); componentHeight = loopHeightMap.remove(widget); pl += cm.getLeft(); pl = Math.max(0, pl); if (hBoxLayoutAlign.equals(HBoxLayoutAlign.MIDDLE)) { int diff = availableHeight - (componentHeight + cm.getTop() + cm.getBottom()); if (diff == 0) { componentTop = pt + cm.getTop(); } else { componentTop = pt + cm.getTop() + (diff / 2); } } else { if (hBoxLayoutAlign.equals(HBoxLayoutAlign.BOTTOM)) { componentTop = h - (pb + cm.getBottom() + componentHeight); } else { componentTop = pt + cm.getTop(); } } boolean component = widget instanceof Component; Component c = null; if (component) { c = (Component) widget; } int width = -1; if (component) { c.setPosition(pl, componentTop); } else { XElement.as(widget.getElement()).setLeftTop(pl, componentTop); } if (getPack().equals(BoxLayoutPack.START) && layoutData.getFlex() > 0) { int add = (int) Math.floor(extraWidth * (layoutData.getFlex() / totalFlex)); allocated += add; if (isAdjustForFlexRemainder() && i == getWidgetCount() - 1) { add += (extraWidth - allocated); } componentWidth += add; width = componentWidth; } if (hBoxLayoutAlign.equals(HBoxLayoutAlign.STRETCH)) { applyLayout(widget, width, Util.constrain(stretchHeight - cm.getTop() - cm.getBottom(), layoutData.getMinSize(), layoutData.getMaxSize())); } else if (hBoxLayoutAlign.equals(HBoxLayoutAlign.STRETCHMAX)) { applyLayout(widget, width, Util.constrain(maxHeight - cm.getTop() - cm.getBottom(), layoutData.getMinSize(), layoutData.getMaxSize())); } else if (width > 0) { applyLayout(widget, width, -1); } pl += componentWidth + cm.getRight(); } // do we need overflow if (enableOverflow) { int runningWidth = 0; for (int i = 0, len = getWidgetCount(); i < len; i++) { Widget widget = getWidget(i); if (widget == more) { continue; } BoxLayoutData layoutData = null; Object d = widget.getLayoutData(); if (d instanceof BoxLayoutData) { layoutData = (BoxLayoutData) d; } else { layoutData = new BoxLayoutData(); } Margins cm = layoutData.getMargins(); if (cm == null) { cm = new Margins(0); } runningWidth += getWidgetWidth(widget); runningWidth += cm.getLeft(); runningWidth += cm.getRight(); } if (runningWidth > w) { hasOverflow = true; onOverflow(); } else { hasOverflow = false; if (more != null && more.getParent() == this) { onUnoverflow(); } } } }