Example usage for com.google.gwt.user.client.ui UIObject isVisible

List of usage examples for com.google.gwt.user.client.ui UIObject isVisible

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui UIObject isVisible.

Prototype

public static boolean isVisible(Element elem) 

Source Link

Document

Returns whether the given element is visible in a way consistent with #setVisible(Element,boolean) .

Usage

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static Element getElementForPositioning0(Element from) {
    assert tempPositioningText == null;
    if (!isVisibleAncestorChain(from)) {
        return null;
    }/*from ww  w.j  av  a  2 s  .  com*/
    boolean hidden = isZeroOffsetDims(from);
    int kidCount = from.getChildCount();
    if (kidCount != 0 && !hidden) {
        return from;
    }
    Node parent = from.getParentNode();
    if (parent != null && parent.getFirstChild() == from && parent.getNodeType() == Node.ELEMENT_NODE
            && !isZeroOffsetDims((Element) parent)) {
        return (Element) parent;
    }
    ClientNodeIterator itr = new ClientNodeIterator(from, ClientNodeIterator.SHOW_ALL);
    Element fromContainingBlock = DomUtils.getContainingBlock(from);
    Node node = from;
    int insertTextIfOffsetMoreThanXChars = 100;
    while ((node = node.getPreviousSibling()) != null) {
        if (node.getNodeType() == Node.TEXT_NODE) {
            insertTextIfOffsetMoreThanXChars -= TextUtils.normalizeWhitespaceAndTrim(node.getNodeValue())
                    .length();
            if (insertTextIfOffsetMoreThanXChars < 0) {
                // this causes a relayout - so we try and avoid. most of the
                // time, positioning elements will contain text (or be from
                // a friendly browser), or be at the start of a block elt)
                tempPositioningText = Document.get().createTextNode("---");
                from.appendChild(tempPositioningText);
                return from;
            }
        }
    }
    // give up after 50 node iterations (big tables maybe)
    int max = 50;
    while ((node = itr.nextNode()) != null && max-- > 0) {
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            if (!isZeroOffsetDims(node.getParentElement()) && node.getNodeName().equalsIgnoreCase("img")) {
                return (Element) node;
            }
            if (!UIObject.isVisible((Element) node)) {
                itr.skipChildren();
            }
        } else {
            // text
            if (!isZeroOffsetDims(node.getParentElement())
                    // we don't want the combined ancestor of everyone...
                    && (!node.getParentElement().isOrHasChild(from) ||
                    // but we do want <p><a><b>*some-text*</b></p>
                            DomUtils.getContainingBlock(node) == fromContainingBlock)) {
                return node.getParentElement();
            }
        }
    }
    return from.getParentElement();
}

From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java

License:Apache License

public static boolean isVisibleAncestorChain(Element e) {
    if (e == null || e.getOwnerDocument() == null) {
        return false;
    }/*from www. j  av  a2 s.c om*/
    Element documentElement = e.getOwnerDocument().getDocumentElement();
    while (e != documentElement) {
        if (!UIObject.isVisible(e)) {
            return false;
        }
        if ("hidden".equals(e.getStyle().getVisibility())) {
            return false;
        }
        Element old = e;
        e = e.getParentElement();
        // detached
        if (e == null) {
            return false;
        }
    }
    return true;
}

From source file:cc.kune.chat.client.ChatClientDefault.java

License:GNU Affero Public License

/**
 * Toggle show dialog./*from   www  . j  av a 2 s. c om*/
 */
private void toggleShowDialog() {
    Log.info("Toggle!");
    final Boolean isVisible = UIObject.isVisible(chatDiv) && !PolymerUtils.isMainSelected();
    showDialog(!isVisible);
}

From source file:com.google.api.explorer.client.history.EmbeddedHistoryItemView.java

License:Apache License

@UiHandler("showHideHeaders")
public void showHide(ClickEvent event) {
    showHideHeaders.setText(UIObject.isVisible(responseHeadersDiv) ? "- Show headers -" : "- Hide headers -");
    UIObject.setVisible(responseHeadersDiv, !UIObject.isVisible(responseHeadersDiv));
}

From source file:com.google.gerrit.client.change.Message.java

License:Apache License

private boolean isOpen() {
    return UIObject.isVisible(message);
}

From source file:com.google.gerrit.client.diff.DraftBox.java

License:Apache License

@Override
boolean isOpen() {
    return UIObject.isVisible(p_view);
}

From source file:com.google.gerrit.client.diff.DraftBox.java

License:Apache License

boolean isEdit() {
    return UIObject.isVisible(p_edit);
}

From source file:com.google.gerrit.client.diff.PublishedBox.java

License:Apache License

@Override
boolean isOpen() {
    return UIObject.isVisible(message);
}

From source file:com.gwtextux.client.widgets.timeline.TimeLine.java

License:Apache License

/**
 * Create TimeLine object//from w w  w .  jav a2s.co  m
 */
public static TimeLine create(List bands, EventSource source, Element divElement, Element clientElement) {
    JavaScriptObject[] bandArr = JavaScriptObjectHelper.listToArray(bands);
    JavaScriptObject jarr = JavaScriptObjectHelper.arrayConvert(bandArr);
    boolean currVisible = UIObject.isVisible(clientElement);
    UIObject.setVisible(clientElement, true);
    TimeLine timeLine = TimeLineImpl.create(jarr, divElement);
    UIObject.setVisible(clientElement, currVisible);
    return timeLine;
}

From source file:com.gwtextux.client.widgets.timeline.TimeLineWidget.java

License:Apache License

/**
 * Is timeline visible within containing view
 *
 * @return visible status//from  w ww.  j  av  a2s . c o  m
 */
public boolean visible() {
    /**
     * There might be an issue around this to do with how many views the widget is embedded down
     * into. This will examine the visibility of the client div and the parent but if you were
     * to put a parent view inside yet another view and stick that inside a tab, you might get
     * into trouble. 
     * */
    Element clientElement = getClientElement();
    Element containerElement = getElement();

    boolean client = UIObject.isVisible(clientElement);
    boolean container = UIObject.isVisible(containerElement);

    return (client && container);
}