Example usage for com.google.gwt.dom.client Style setVisibility

List of usage examples for com.google.gwt.dom.client Style setVisibility

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Style setVisibility.

Prototype

public void setVisibility(Visibility value) 

Source Link

Usage

From source file:com.alkacon.geranium.client.util.TextMetrics.java

License:Open Source License

/**
 * Binds this text metrics instance to an element from which to copy existing
 * CSS styles that can affect the size of the rendered text.<p>
 * //from  www. ja v  a  2 s.  co m
 * @param element the element
 * @param attributes the attributes to bind
 */
protected void bind(Element element, DomUtil.Style... attributes) {

    if (m_elem == null) {
        // create playground
        m_elem = DOM.createDiv();
        Style style = m_elem.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setPosition(Style.Position.ABSOLUTE);
        style.setLeft(-5000, Style.Unit.PX);
        style.setTop(-5000, Style.Unit.PX);
    }
    // copy all relevant CSS properties
    Style style = m_elem.getStyle();
    for (DomUtil.Style attr : attributes) {
        String attrName = attr.toString();
        style.setProperty(attrName, DomUtil.getCurrentStyle(element, attr));
    }
    // append playground
    RootPanel.getBodyElement().appendChild(m_elem);
}

From source file:com.axlight.gbrain.client.MainPane.java

License:Apache License

private void relocateCenter(int posX, int posY) {
    final Style glassStyle = Document.get().getElementById("gbrain-glass").getStyle();
    glassStyle.setWidth(viewWidth, Unit.PX);
    glassStyle.setHeight(viewHeight, Unit.PX);
    glassStyle.setVisibility(Visibility.VISIBLE);
    viewX = posX - viewWidth / 2;/*from w  ww. j  a v a 2  s.co m*/
    viewY = posY - viewHeight / 2;
    nodeManager.updateView(viewX, viewY);
    coordinate.updateView(viewX, viewY);
    new Timer() {
        public void run() {
            int screenWidth = getWindowScreenWidth();
            int screenHeight = getWindowScreenHeight();
            int left = viewWidth / 2 - screenWidth / 2;
            int top = viewHeight / 2 - screenHeight / 2;
            Window.scrollTo(left, top);
            setWidgetPosition(buttonPanel, left, top + screenHeight - buttonPanel.getOffsetHeight());
            glassStyle.setVisibility(Visibility.HIDDEN);
        }
    }.schedule(500);
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.downloader.CubaFileDownloaderConnector.java

License:Apache License

public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();

        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);

        iframe.setFrameBorder(0);/*from ww  w. ja v a  2  s  .  co m*/
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}

From source file:com.vaadin.client.extensions.FileDownloaderConnector.java

License:Apache License

@Override
public void onClick(ClickEvent event) {
    final String url = getResourceUrl("dl");
    if (url != null && !url.isEmpty()) {
        BrowserInfo browser = BrowserInfo.get();
        if (browser.isIOS()) {
            Window.open(url, "_blank", "");
        } else {//  w  ww.  jav a 2s  . co m
            if (iframe != null) {
                // make sure it is not on dom tree already, might start
                // multiple downloads at once
                iframe.removeFromParent();
            }
            iframe = Document.get().createIFrameElement();

            Style style = iframe.getStyle();
            style.setVisibility(Visibility.HIDDEN);
            style.setHeight(0, Unit.PX);
            style.setWidth(0, Unit.PX);

            iframe.setFrameBorder(0);
            iframe.setTabIndex(-1);
            iframe.setSrc(url);
            RootPanel.getBodyElement().appendChild(iframe);
        }
    }
}

From source file:com.vaadin.client.metadata.ConnectorBundleLoader.java

License:Apache License

private void notice(String productName) {
    if (notice == null) {
        notice = new HTML();
        notice.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                notice.removeFromParent();
            }//from   w  w w .j  av  a 2 s  .  c om
        });
        notice.addTouchStartHandler(new TouchStartHandler() {
            public void onTouchStart(TouchStartEvent event) {
                notice.removeFromParent();
            }
        });
    }
    String msg = notice.getText().trim();
    msg += msg.isEmpty() ? "Using Evaluation License of: " : ", ";
    notice.setText(msg + productName);
    RootPanel.get().add(notice);

    notice.getElement().setClassName("");
    Style s = notice.getElement().getStyle();

    s.setPosition(Position.FIXED);
    s.setTextAlign(TextAlign.CENTER);
    s.setRight(0, Unit.PX);
    s.setLeft(0, Unit.PX);
    s.setBottom(0, Unit.PX);
    s.setProperty("padding", "0.5em 1em");

    s.setProperty("font-family", "sans-serif");
    s.setFontSize(12, Unit.PX);
    s.setLineHeight(1.1, Unit.EM);

    s.setColor("white");
    s.setBackgroundColor("black");
    s.setOpacity(0.7);

    s.setZIndex(2147483646);
    s.setProperty("top", "auto");
    s.setProperty("width", "auto");
    s.setDisplay(Display.BLOCK);
    s.setWhiteSpace(WhiteSpace.NORMAL);
    s.setVisibility(Visibility.VISIBLE);
    s.setMargin(0, Unit.PX);
}

From source file:com.vaadin.client.ui.orderedlayout.VAbstractOrderedLayout.java

License:Apache License

/**
 * Assigns relative sizes to the children that should expand based on their
 * expand ratios.// w  w  w . jav  a2 s. com
 */
public void updateExpandedSizes() {
    // Ensure the expand wrapper is in place
    if (expandWrapper == null) {
        expandWrapper = DOM.createDiv();
        expandWrapper.setClassName("v-expand");

        // Detach all widgets before modifying DOM
        for (Widget widget : getChildren()) {
            orphan(widget);
        }

        while (getElement().getChildCount() > 0) {
            Node el = getElement().getChild(0);
            expandWrapper.appendChild(el);
        }
        getElement().appendChild(expandWrapper);

        // Attach all widgets again
        for (Widget widget : getChildren()) {
            adopt(widget);
        }
    }

    // Sum up expand ratios to get the denominator
    double total = 0;
    for (Slot slot : widgetToSlot.values()) {
        // FIXME expandRatio might be <0
        total += slot.getExpandRatio();
    }

    // Give each expanded child its own share
    for (Slot slot : widgetToSlot.values()) {

        Element slotElement = slot.getElement();
        slotElement.removeAttribute("aria-hidden");

        Style slotStyle = slotElement.getStyle();
        slotStyle.clearVisibility();
        slotStyle.clearMarginLeft();
        slotStyle.clearMarginTop();

        if (slot.getExpandRatio() != 0) {
            // FIXME expandRatio might be <0
            double size = 100 * (slot.getExpandRatio() / total);

            if (vertical) {
                slot.setHeight(size + "%");
                if (slot.hasRelativeHeight()) {
                    Util.notifyParentOfSizeChange(this, true);
                }
            } else {
                slot.setWidth(size + "%");
                if (slot.hasRelativeWidth()) {
                    Util.notifyParentOfSizeChange(this, true);
                }
            }

        } else if (slot.isRelativeInDirection(vertical)) {
            // Relative child without expansion gets no space at all
            if (vertical) {
                slot.setHeight("0");
            } else {
                slot.setWidth("0");
            }
            slotStyle.setVisibility(Visibility.HIDDEN);
            slotElement.setAttribute("aria-hidden", "true");

        } else {
            // Non-relative child without expansion should be unconstrained
            if (BrowserInfo.get().isIE8()) {
                // unconstrained in IE8 is auto
                if (vertical) {
                    slot.setHeight("auto");
                } else {
                    slot.setWidth("auto");
                }
            } else {
                if (vertical) {
                    slotStyle.clearHeight();
                } else {
                    slotStyle.clearWidth();
                }
            }
        }
    }
}

From source file:geogebra.web.gui.app.docklayout.LayoutImpl.java

License:Apache License

protected static DivElement createRuler(Unit widthUnit, Unit heightUnit) {
    DivElement ruler = Document.get().createDivElement();
    ruler.setInnerHTML("&nbsp;");
    Style style = ruler.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(-32767);/*from  w w w.java2s .c  o m*/

    // Position the ruler off the top edge, double the size just to be
    // extra sure it doesn't show up on the screen.
    style.setTop(-20, heightUnit);

    // Note that we are making the ruler element 10x10, because some browsers
    // generate non-integral ratios (e.g., 1em == 13.3px), so we need a little
    // extra precision.
    style.setWidth(10, widthUnit);
    style.setHeight(10, heightUnit);

    style.setVisibility(Visibility.HIDDEN);
    State.HIDDEN.set(ruler, true);
    return ruler;
}

From source file:io.pelle.mango.client.gwt.widgets.Spacer.java

License:Open Source License

public Spacer(double width) {
    setElement(DOM.createSpan());/*from   w ww . j ava 2  s  .c o  m*/
    Style style = getElement().getStyle();
    style.setVisibility(Visibility.HIDDEN);
    style.setMarginLeft(width, Unit.EM);
}

From source file:jetbrains.jetpad.cell.toDom.CellContainerToDomMapper.java

License:Apache License

private void refreshLineHighlight() {
    if (myLineHighlightUpToDate || !isAttached())
        return;//w ww  .  ja  v a2s  . co  m
    Cell current = getSource().focusedCell.get();
    for (Element e : Arrays.asList(myLineHighlight1, myLineHighlight2)) {
        Style style = e.getStyle();
        if (current == null || !Cells.isLeaf(current)) {
            style.setVisibility(Style.Visibility.HIDDEN);
        } else {
            int deltaTop = myContent.getAbsoluteTop() - getTarget().getAbsoluteTop();
            style.setVisibility(Style.Visibility.VISIBLE);
            int rootTop = myContent.getAbsoluteTop();
            final Element currentElement = getElement(current);
            int currentTop = currentElement.getAbsoluteTop();
            style.setTop(currentTop - rootTop + deltaTop, Style.Unit.PX);
            style.setHeight(currentElement.getClientHeight(), Style.Unit.PX);
            if (e == myLineHighlight2) {
                style.setWidth(0, Style.Unit.PX);
                style.setWidth(getTarget().getScrollWidth(), Style.Unit.PX);
            }
        }
    }
    myLineHighlightUpToDate = true;
}

From source file:org.cruxframework.crux.widgets.client.swappanel.HorizontalSwapPanel.java

License:Apache License

/**
 * Constructor//from  w ww. ja  v a  2s  . c  om
 */
public HorizontalSwapPanel() {
    contentPanel = new FlowPanel();
    initWidget(contentPanel);
    setStyleName("crux-HorizontalSwapPanel");

    Style style = contentPanel.getElement().getStyle();
    style.setPosition(Position.RELATIVE);
    style.setOverflow(Overflow.HIDDEN);
    style.setWidth(100, Unit.PCT);
    style.setVisibility(Visibility.VISIBLE);
    style.setOpacity(1);

    configureCurrentPanel();
    configureNextPanel();

    Transition.hideBackface(currentPanel);
    Transition.hideBackface(nextPanel);

    contentPanel.add(currentPanel);
    contentPanel.add(nextPanel);
}