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

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

Introduction

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

Prototype

public void setPosition(Position value) 

Source Link

Usage

From source file:com.eas.widgets.boxes.DecoratorBox.java

public DecoratorBox(HasValue<T> aDecorated) {
    super();/* w  w  w .j  a va2  s.  c  o  m*/
    decorated = aDecorated;
    if (decorated instanceof HasValue<?>) {
        decorated.addValueChangeHandler(new ValueChangeHandler<T>() {

            @Override
            public void onValueChange(ValueChangeEvent<T> event) {
                setClearButtonVisible(nullable && event.getValue() != null);
            }
        });
    }
    if (decorated instanceof HasDecorations) {
        HasWidgets container = ((HasDecorations) decorated).getContainer();
        ((Widget) container).addStyleName("decorator");
        container.add(selectButton);
        container.add(clearButton);
        initWidget((Widget) decorated);
    } else {
        CommonResources.INSTANCE.commons().ensureInjected();
        ((Widget) decorated).getElement().addClassName(CommonResources.INSTANCE.commons().borderSized());
        Style style = ((Widget) decorated).getElement().getStyle();
        style.setMargin(0, Style.Unit.PX);
        style.setPosition(Style.Position.ABSOLUTE);
        style.setDisplay(Style.Display.INLINE_BLOCK);
        style.setLeft(0, Style.Unit.PX);
        style.setTop(0, Style.Unit.PX);
        style.setHeight(100, Style.Unit.PCT);
        style.setWidth(100, Style.Unit.PCT);
        style.setOutlineStyle(Style.OutlineStyle.NONE);
        FlowPanel panel = new FlowPanel();
        panel.addStyleName("decorator");
        initWidget(panel);
        panel.add((Widget) decorated);
        panel.add(selectButton);
        panel.add(clearButton);
    }

    ((Widget) decorated).addStyleName("decorator-content");

    selectButton.getElement().addClassName("decorator-select");
    selectButton.getElement().getStyle().setDisplay(Style.Display.NONE);
    selectButton.getElement().getStyle().setHeight(100, Style.Unit.PCT);
    selectButton.getElement().getStyle().setPosition(Style.Position.RELATIVE);
    clearButton.getElement().addClassName("decorator-clear");
    clearButton.getElement().getStyle().setDisplay(Style.Display.NONE);
    clearButton.getElement().getStyle().setHeight(100, Style.Unit.PCT);
    clearButton.getElement().getStyle().setPosition(Style.Position.RELATIVE);

    selectButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            selectValue();
        }
    }, ClickEvent.getType());
    clearButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            clearValue();
            setFocus(true);
        }
    }, ClickEvent.getType());
    organizeButtonsContent();

    getElement().<XElement>cast().addResizingTransitionEnd(this);

    if (decorated instanceof HasValue<?>) {
        changeValueHandler = decorated.addValueChangeHandler(new ValueChangeHandler<T>() {

            @Override
            public void onValueChange(ValueChangeEvent<T> event) {
                fireValueChangeEvent();
            }
        });
    }

    if (decorated instanceof HasKeyDownHandlers) {
        keyDownHandler = ((HasKeyDownHandlers) decorated).addKeyDownHandler(new KeyDownHandler() {

            @Override
            public void onKeyDown(KeyDownEvent event) {
                KeyDownEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }
        });
    }
    if (decorated instanceof HasKeyUpHandlers) {
        keyUpHandler = ((HasKeyUpHandlers) decorated).addKeyUpHandler(new KeyUpHandler() {

            @Override
            public void onKeyUp(KeyUpEvent event) {
                KeyUpEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }
        });
    }
    if (decorated instanceof HasKeyPressHandlers) {
        keyPressHandler = ((HasKeyPressHandlers) decorated).addKeyPressHandler(new KeyPressHandler() {

            @Override
            public void onKeyPress(KeyPressEvent event) {
                KeyPressEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }
        });
    }
    if (decorated instanceof HasFocusHandlers) {
        focusHandler = ((HasFocusHandlers) decorated).addFocusHandler(new FocusHandler() {

            @Override
            public void onFocus(FocusEvent event) {
                FocusEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }

        });
    }
    if (decorated instanceof HasBlurHandlers) {
        blurHandler = ((HasBlurHandlers) decorated).addBlurHandler(new BlurHandler() {

            @Override
            public void onBlur(BlurEvent event) {
                BlurEvent.fireNativeEvent(event.getNativeEvent(), DecoratorBox.this);
            }

        });
    }

}

From source file:com.google.mobile.trippy.web.client.widget.InfoWindowView.java

License:Apache License

@Override
public void draw() {

    HasPoint point = getProjection().fromLatLngToDivPixel(position);

    Style contentStyle = infoWindowContent.getElement().getStyle();
    contentStyle.setPosition(Position.ABSOLUTE);
    int mapWidth = getMap().getDiv().getClientWidth();

    int infoWidth = infoWindowContent.getOffsetWidth();
    int pos = (int) (point.getX() - (infoWidth / 2));
    int shift = infoWidth - (getMap().getDiv().getAbsoluteRight() - pos);
    //    if (shift > 0) {
    //      pos -= shift;
    //    }//from   w w  w . j a v  a2 s  .  co  m
    contentStyle.setLeft(pos, Unit.PX);
    contentStyle.setTop(point.getY() - 70, Unit.PX);
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadProgressWindow.java

License:Apache License

private void fixIE8FocusCaptureIssue() {
    Element e = DOM.createInputText();
    Style elemStyle = e.getStyle();
    elemStyle.setPosition(Style.Position.ABSOLUTE);
    elemStyle.setTop(-10, Style.Unit.PX);
    elemStyle.setWidth(0, Style.Unit.PX);
    elemStyle.setHeight(0, Style.Unit.PX);

    contentPanel.getElement().appendChild(e);
    e.focus();// ww w.j av a2  s . c  o  m
    contentPanel.getElement().removeChild(e);
}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.gridlayout.VDDGridLayout.java

License:Apache License

/**
 * Emphasizes a component container when user is hovering a dragged
 * component over the container.//  w  w w. ja v a2  s .c om
 * 
 * @param cell
 *            The container
 * @param event
 */
protected void emphasis(CellDetails cell, VDragEvent event) {

    Style shadowStyle = dragShadow.getElement().getStyle();
    shadowStyle.setPosition(Position.ABSOLUTE);
    shadowStyle.setWidth(cell.width, Unit.PX);
    shadowStyle.setHeight(cell.height, Unit.PX);
    shadowStyle.setLeft(cell.x, Unit.PX);
    shadowStyle.setTop(cell.y, Unit.PX);

    // Remove any existing empasis
    deEmphasis();

    // Ensure we are not dragging ourself into ourself
    ComponentConnector draggedConnector = (ComponentConnector) event.getTransferable()
            .getData(Constants.TRANSFERABLE_DETAIL_COMPONENT);

    if (draggedConnector != null && draggedConnector.getWidget() == VDDGridLayout.this) {
        return;
    }

    HorizontalDropLocation hl = getHorizontalDropLocation(cell, event);
    VerticalDropLocation vl = getVerticalDropLocation(cell, event);

    // Apply over style
    setStyleName(dragShadow.getElement(), OVER, true);

    // Add vertical location dependent style
    setStyleName(dragShadow.getElement(), OVER + "-" + vl.toString().toLowerCase(), true);

    // Add horizontal location dependent style
    setStyleName(dragShadow.getElement(), OVER + "-" + hl.toString().toLowerCase(), true);

}

From source file:com.haulmont.cuba.web.widgets.client.addons.dragdroplayouts.ui.util.IframeCoverUtility.java

License:Apache License

/**
 * Adds an iframe cover over an Embedded component
 * //from w  w w  . j av a 2s .co  m
 * @param iframe
 *            The iframe element
 * @return The element which covers the iframe
 */
private static Element addIframeCover(Element iframe) {
    if (iframeCoverMap.containsKey(iframe)) {
        return iframeCoverMap.get(iframe);
    }

    // Get dimensions
    String iframeWidth = iframe.getAttribute("width");
    String iframeHeight = iframe.getAttribute("height");

    Style iframeStyle = iframe.getStyle();

    if (!iframeWidth.equals("") && !iframeHeight.equals("")) {
        iframeStyle.setPosition(Position.ABSOLUTE);
        iframeStyle.setTop(0, Unit.PX);
        iframeStyle.setLeft(0, Unit.PX);
    }

    // Create the cover element
    Element coverContainer = DOM.createDiv();
    DOM.setStyleAttribute(coverContainer, "width", iframeWidth);
    DOM.setStyleAttribute(coverContainer, "height", iframeHeight);

    coverContainer.setClassName("v-dragdrop-iframe-container");
    coverContainer.getStyle().setPosition(Position.RELATIVE);
    iframe.getParentElement().appendChild(coverContainer);

    // Move iframe to cover container
    iframe.getParentElement().replaceChild(coverContainer, iframe);
    coverContainer.appendChild(iframe);

    // Style the cover
    Element cover = DOM.createDiv();
    cover.setClassName(SHIM_STYLENAME);
    Style coverStyle = cover.getStyle();
    coverStyle.setPosition(Position.ABSOLUTE);
    coverStyle.setWidth(100, Unit.PCT);
    coverStyle.setHeight(100, Unit.PCT);
    coverStyle.setTop(0, Unit.PX);
    coverStyle.setLeft(0, Unit.PX);

    coverContainer.appendChild(cover);

    iframeCoverMap.put(iframe, coverContainer);

    return coverContainer;
}

From source file:com.ksyzt.gwt.client.ui.richeditor.RichTextToolbar.java

License:Open Source License

/**
 * Inits the popup panel.//from  w  w w.  ja  va 2 s. c o m
 */
private void initPopupPanel() {
    m_ap_shadow = new HTMLPanel("div", "");
    m_ap_content = new HTMLPanel("div", "");
    m_ap_line = new HTMLPanel("div", "");

    Style style = m_ap_content.getElement().getStyle();
    style.setProperty("border", "solid 1px skyblue");
    style.setBackgroundColor("white");
    style.setPadding(5, Unit.PX);
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(1000000);

    style = m_ap_shadow.getElement().getStyle();
    style.setBackgroundColor("#f0f0f0");
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(999999);

    m_ap_line.setHeight("1px");
    style = m_ap_line.getElement().getStyle();
    style.setBackgroundColor("white");
    style.setPosition(Position.ABSOLUTE);
    style.setZIndex(1000001);

    RootPanel.get().add(m_ap_shadow);
    RootPanel.get().add(m_ap_content);
    RootPanel.get().add(m_ap_line);

    m_ap_content.setVisible(false);

    m_ap_shadow.setVisible(false);

    m_ap_line.setVisible(false);

}

From source file:com.smartgwt.mobile.client.internal.util.AnimationUtil.java

License:Open Source License

/**
 * Flip-transition between the old and new widget.
 *
 * @param oldPane the old widget//from w  w w . ja va 2  s.co m
 * @param newPane the new widget
 * @param container the container panel
 */
public static void flipTransition(final Canvas oldPane, Canvas newPane, final Layout container) {
    Style oldStyle = oldPane.getElement().getStyle();
    Style newStyle = newPane.getElement().getStyle();

    oldStyle.setPosition(Style.Position.ABSOLUTE);
    newStyle.setPosition(Style.Position.ABSOLUTE);

    // flip the new element (instantly)
    newStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(), "none");
    newStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "rotateY(-180deg)");

    // set both to invisible when flipped
    oldStyle.setProperty(DOMConstants.INSTANCE.getBackfaceVisibilityPropertyName(), "hidden");
    newStyle.setProperty(DOMConstants.INSTANCE.getBackfaceVisibilityPropertyName(), "hidden");
    // will be initially invisible
    container.addMember(newPane);

    // set both to animate
    oldStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(),
            DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + " 0.3s ease-in-out");
    newStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(),
            DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + " 0.3s ease-in-out");

    // rotate old to 180, making it invisible since the back face is showing
    oldStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "rotateY(180deg)");
    // flip the new widget back to 0
    newStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "rotateY(0deg)");

    new Timer() {
        public void run() {
            container.removeMember(oldPane);
        }
    }.schedule(350);
}

From source file:com.smartgwt.mobile.client.widgets.layout.NavigationBar.java

License:Open Source License

@SGWTInternal
public void _fixPosition() {
    assert Canvas._getFixNavigationBarPositionDuringKeyboardFocus();
    if (unfixPositionTimer != null) {
        unfixPositionTimer.cancel();/*  www  . ja  v  a  2  s.  com*/
        unfixPositionTimer = null;
    }
    if (!isPositionFixed) {
        final SuperElement elem = getElement().<SuperElement>cast();
        final Style elemStyle = elem.getStyle();
        isPositionFixed = true;
        elemStyle.setPosition(Style.Position.FIXED);
        elemStyle.setProperty(DOMConstants.INSTANCE.getTransitionShorthandPropertyName(),
                DOMConstants.INSTANCE.getTransformPropertyNameForCSSText() + " 200ms");
        //elemStyle.setProperty(DOMConstants.INSTANCE.getTransformPropertyName(), "none");
    }

    // In a UIWebView, the 'scroll' event is not fired on the window when the Previous/Next
    // buttons are used to move from <input> to <input>. It is when the app is run in
    // Mobile Safari, however.
    if (Canvas.isUIWebView()) {
        if (mockScrollTimer != null)
            mockScrollTimer.cancel();
        mockScrollTimer = new Timer() {
            @Override
            public void run() {
                assert this == mockScrollTimer;
                mockScrollTimer = null;
                _updateFixedPosition();
            }
        };
        mockScrollTimer.schedule(1);
    }
}

From source file:com.vaadin.client.debug.internal.Highlight.java

License:Apache License

/**
 * Highlight the given {@link Element} using the given color.
 * <p>//  ww w  .ja  v a  2s  .c  o  m
 * Pass the returned highlight {@link Element} to {@link #hide(Element)} to
 * remove this particular highlight.
 * </p>
 * 
 * @param element
 *            Element to highlight
 * @param color
 *            Color of highlight
 * @return Highlight element
 */
static Element show(Element element, String color) {
    if (element != null) {
        if (highlights == null) {
            highlights = new HashSet<Element>();
        }

        Element highlight = DOM.createDiv();
        Style style = highlight.getStyle();
        style.setTop(element.getAbsoluteTop(), Unit.PX);
        style.setLeft(element.getAbsoluteLeft(), Unit.PX);
        int width = element.getOffsetWidth();
        if (width < MIN_WIDTH) {
            width = MIN_WIDTH;
        }
        style.setWidth(width, Unit.PX);
        int height = element.getOffsetHeight();
        if (height < MIN_HEIGHT) {
            height = MIN_HEIGHT;
        }
        style.setHeight(height, Unit.PX);
        RootPanel.getBodyElement().appendChild(highlight);

        style.setPosition(Position.ABSOLUTE);
        style.setZIndex(VWindow.Z_INDEX + 1000);
        style.setBackgroundColor(color);
        style.setOpacity(DEFAULT_OPACITY);
        if (BrowserInfo.get().isIE()) {
            style.setProperty("filter", "alpha(opacity=" + (DEFAULT_OPACITY * 100) + ")");
        }

        highlights.add(highlight);

        return highlight;
    }
    return null;
}

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  a v a  2 s .co  m*/
        });
        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);
}