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

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

Introduction

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

Prototype

public void setTop(double value, Unit unit) 

Source Link

Usage

From source file:com.vaadin.terminal.gwt.client.ui.FocusElementPanel.java

License:Open Source License

@Override
public void setWidget(Widget w) {
    super.setWidget(w);
    if (focusElement.getParentElement() == null) {
        Style style = focusElement.getStyle();
        style.setPosition(Position.FIXED);
        style.setTop(0, Unit.PX);
        style.setLeft(0, Unit.PX);//ww  w. j a v  a2s . c  o  m
        getElement().appendChild(focusElement);
        /* Sink from focusElement too as focus and blur don't bubble */
        DOM.sinkEvents((com.google.gwt.user.client.Element) focusElement.cast(), Event.FOCUSEVENTS);
        // revert to original, not focusable
        getElement().setPropertyObject("tabIndex", null);
    } else {
        moveFocusElementAfterWidget();
    }
}

From source file:com.vaadin.terminal.gwt.client.VDebugConsole.java

License:Open Source License

public void init() {
    panel = new FlowPanel();
    if (!quietMode) {
        DOM.appendChild(getContainerElement(), caption);
        setWidget(panel);/*from  ww w  .j  a v  a 2 s.c om*/
        caption.setClassName("v-debug-console-caption");
        setStyleName("v-debug-console");
        getElement().getStyle().setZIndex(20000);
        getElement().getStyle().setOverflow(Overflow.HIDDEN);

        sinkEvents(Event.ONDBLCLICK);

        sinkEvents(Event.MOUSEEVENTS);

        panel.setStyleName("v-debug-console-content");

        caption.setInnerHTML("Debug window");
        caption.getStyle().setHeight(25, Unit.PX);
        caption.setTitle(help);

        show();
        setToDefaultSizeAndPos();

        actions = new HorizontalPanel();
        Style style = actions.getElement().getStyle();
        style.setPosition(Position.ABSOLUTE);
        style.setBackgroundColor("#666");
        style.setLeft(135, Unit.PX);
        style.setHeight(25, Unit.PX);
        style.setTop(0, Unit.PX);

        actions.add(clear);
        actions.add(restart);
        actions.add(forceLayout);
        actions.add(analyzeLayout);
        actions.add(highlight);
        highlight.setTitle(
                "Select a component and print details about it to the server log and client side console.");
        actions.add(savePosition);
        savePosition.setTitle("Saves the position and size of debug console to a cookie");
        actions.add(autoScroll);
        actions.add(hostedMode);
        if (Location.getParameter("gwt.codesvr") != null) {
            hostedMode.setValue(true);
        }
        hostedMode.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                if (hostedMode.getValue()) {
                    addHMParameter();
                } else {
                    removeHMParameter();
                }
            }

            private void addHMParameter() {
                UrlBuilder createUrlBuilder = Location.createUrlBuilder();
                createUrlBuilder.setParameter("gwt.codesvr", "localhost:9997");
                Location.assign(createUrlBuilder.buildString());
            }

            private void removeHMParameter() {
                UrlBuilder createUrlBuilder = Location.createUrlBuilder();
                createUrlBuilder.removeParameter("gwt.codesvr");
                Location.assign(createUrlBuilder.buildString());

            }
        });

        autoScroll.setTitle("Automatically scroll so that new messages are visible");

        panel.add(actions);

        panel.add(new HTML("<i>" + help + "</i>"));

        clear.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                int width = panel.getOffsetWidth();
                int height = panel.getOffsetHeight();
                panel = new FlowPanel();
                panel.setPixelSize(width, height);
                panel.setStyleName("v-debug-console-content");
                panel.add(actions);
                setWidget(panel);
            }
        });

        restart.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {

                String queryString = Window.Location.getQueryString();
                if (queryString != null && queryString.contains("restartApplications")) {
                    Window.Location.reload();
                } else {
                    String url = Location.getHref();
                    String separator = "?";
                    if (url.contains("?")) {
                        separator = "&";
                    }
                    if (!url.contains("restartApplication")) {
                        url += separator;
                        url += "restartApplication";
                    }
                    if (!"".equals(Location.getHash())) {
                        String hash = Location.getHash();
                        url = url.replace(hash, "") + hash;
                    }
                    Window.Location.replace(url);
                }

            }
        });

        forceLayout.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                // TODO for each client in appconf force layout
                // VDebugConsole.this.client.forceLayout();
            }
        });

        analyzeLayout.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                List<ApplicationConnection> runningApplications = ApplicationConfiguration
                        .getRunningApplications();
                for (ApplicationConnection applicationConnection : runningApplications) {
                    applicationConnection.analyzeLayouts();
                }
            }
        });
        analyzeLayout.setTitle("Analyzes currently rendered view and "
                + "reports possible common problems in usage of relative sizes."
                + "Will cause server visit/rendering of whole screen and loss of"
                + " all non committed variables form client side.");

        savePosition.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                String pos = getAbsoluteLeft() + "," + getAbsoluteTop() + "," + getOffsetWidth() + ","
                        + getOffsetHeight() + "," + autoScroll.getValue();
                Cookies.setCookie(POS_COOKIE_NAME, pos);
            }
        });

        highlight.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final Label label = new Label("--");
                log("<i>Use mouse to select a component or click ESC to exit highlight mode.</i>");
                panel.add(label);
                highlightModeRegistration = Event.addNativePreviewHandler(new HighlightModeHandler(label));

            }
        });

    }
    log("Starting Vaadin client side engine. Widgetset: " + GWT.getModuleName());

    log("Widget set is built on version: " + ApplicationConfiguration.VERSION);

    logToDebugWindow("<div class=\"v-theme-version v-theme-version-"
            + ApplicationConfiguration.VERSION.replaceAll("\\.", "_") + "\">Warning: widgetset version "
            + ApplicationConfiguration.VERSION + " does not seem to match theme version </div>", true);

}

From source file:com.vaadin.terminal.gwt.client.VUIDLBrowser.java

License:Open Source License

static void highlight(Paintable paintable) {
    Widget w = (Widget) paintable;/*from   w w w .j a v  a 2s.c  o m*/
    if (w != null) {
        Style style = highlight.getStyle();
        style.setTop(w.getAbsoluteTop(), Unit.PX);
        style.setLeft(w.getAbsoluteLeft(), Unit.PX);
        style.setWidth(w.getOffsetWidth(), Unit.PX);
        style.setHeight(w.getOffsetHeight(), Unit.PX);
        RootPanel.getBodyElement().appendChild(highlight);
    }
}

From source file:de.swm.commons.mobile.client.widgets.scroll.ScrollPanel.java

License:Apache License

/**
 * Sets the top stype in pixel/* ww w.j  av a  2 s. c  om*/
 *
 * @param top the top syle
 */

private void setStyleTop(int top) {
    Style style = getWidget().getElement().getStyle();
    style.setTop(top, Unit.PX);
}

From source file:edu.bsu.storygame.html.HtmlNativeTextField.java

License:Open Source License

@Override
public void setBounds(IRectangle bounds) {
    Style style = element.getStyle();
    style.setLeft(bounds.x(), Style.Unit.PX);
    style.setTop(bounds.y(), Style.Unit.PX);
    style.setWidth(bounds.width(), Style.Unit.PX);
    style.setHeight(bounds.height(), Style.Unit.PX);
}

From source file:fi.jasoft.draganddrop.client.DragAndDropConnector.java

License:Apache License

private static void updateDragImagePosition(NativeEvent event) {
    if (dragElement != null) {
        Style style = dragElement.getStyle();
        int clientY = Util.getTouchOrMouseClientY(event);
        int clientX = Util.getTouchOrMouseClientX(event);
        style.setTop(clientY, Unit.PX);
        style.setLeft(clientX, Unit.PX);
    }// w w  w . j a  va2  s  .c  o  m
}

From source file:fi.jasoft.dragdroplayouts.client.ui.gridlayout.VDDGridLayout.java

License:Apache License

/**
 * Emphasizes a component container when user is hovering a dragged component over the container.
 * //from   w  ww. j a v  a2s.  co  m
 * @param container 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
    UIObject.setStyleName(dragShadow.getElement(), OVER, true);

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

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

}

From source file:fr.putnami.pwt.core.widget.client.Affix.java

License:Open Source License

protected void toggleAffix(Affixed affix) {
    Element e = this.getElement();
    Style style = e.getStyle();

    if (this.affixed != affix) {
        this.clearElementStyle();
        this.affixed = affix;
        StyleUtils.addStyle(e, this.affixed);
    }//from w  w w.j  av a2  s. c  om

    switch (affix) {
    case AFFIX:
        style.setTop(this.offsetTop, Unit.PX);
        style.setWidth(this.offsetWidth, Unit.PX);
        style.setHeight(this.offsetHeight, Unit.PX);
        style.setZIndex(this.layerIndex);
        e.getParentElement().getStyle().setPaddingTop(this.offsetHeight, Unit.PX);
        break;
    case BOTTOM:
        int docHeigth = Document.get().getScrollHeight();
        int scrollTop = Window.getScrollTop();

        int bottom = this.offsetBottom - (docHeigth - scrollTop - this.clientHeigth);
        if (this.fixBottom != Integer.MIN_VALUE) {
            bottom = Math.max(bottom, this.fixBottom);
        }
        style.setPosition(Position.FIXED);
        style.setBottom(bottom, Unit.PX);
        style.setWidth(this.offsetWidth, Unit.PX);
        style.setHeight(this.offsetHeight, Unit.PX);
        style.setZIndex(this.layerIndex);
        break;
    default:
        break;
    }
}

From source file:fr.putnami.pwt.core.widget.client.base.AbstractHover.java

License:Open Source License

private void resetPosition(Element toPositionedElement, Widget relativeTo, Placement placement) {
    Element relativeElement = relativeTo.getElement();

    com.google.gwt.dom.client.Style elementStyle = toPositionedElement.getStyle();
    int tooltipWidth = toPositionedElement.getOffsetWidth();
    int tooltipHeight = toPositionedElement.getOffsetHeight();

    int targetWidth = relativeElement.getOffsetWidth();
    int targetHeight = relativeElement.getOffsetHeight();
    int targetTop = relativeElement.getOffsetTop();
    int targetLeft = relativeElement.getOffsetLeft();

    elementStyle.setPosition(Position.ABSOLUTE);
    switch (placement) {
    case TOP://from   w  w w  .  j a  va 2s  . com
        elementStyle.setLeft(targetLeft + targetWidth / 2 - tooltipWidth / 2, Unit.PX);
        elementStyle.setTop(targetTop - tooltipHeight, Unit.PX);
        break;
    case BOTTOM:
        elementStyle.setLeft(targetLeft + targetWidth / 2 - tooltipWidth / 2, Unit.PX);
        elementStyle.setTop(targetTop + targetHeight, Unit.PX);
        break;
    case LEFT:
        elementStyle.setLeft(targetLeft - tooltipWidth, Unit.PX);
        elementStyle.setTop(targetTop + targetHeight / 2 - tooltipHeight / 2, Unit.PX);
        break;
    case RIGHT:
        elementStyle.setLeft(targetLeft + targetWidth, Unit.PX);
        elementStyle.setTop(targetTop + targetHeight / 2 - tooltipHeight / 2, Unit.PX);
        break;
    default:
        break;
    }
}

From source file:fr.putnami.pwt.core.widget.client.InputDatePicker.java

License:Open Source License

public void popup(Widget container, Widget relativeTo) {
    this.setVisible(true);
    StyleUtils.addStyle(this, InputDatePicker.STYLE_POPUP);
    RootPanel.get().add(this);

    Element positioningElement = this.getElement();
    Element relativeElement = relativeTo.getElement();

    int targetHeight = relativeElement.getOffsetHeight();
    int targetTop = relativeElement.getAbsoluteTop();

    int positioningWidth = positioningElement.getOffsetWidth();
    int targetRight = relativeElement.getAbsoluteRight();

    Style elementStyle = positioningElement.getStyle();
    elementStyle.setPosition(Position.ABSOLUTE);
    elementStyle.setLeft(targetRight - positioningWidth, Unit.PX);
    elementStyle.setTop(targetTop + targetHeight, Unit.PX);

    StyleUtils.addStyle(this, InputDatePicker.STYLE_FADE);
    StyleUtils.addStyle(this, InputDatePicker.STYLE_SHOW);

    this.setFocus(true);

    if (this.popupBlurHandler == null) {
        this.popupBlurHandler = this.addBlurHandler(new BlurHandler() {

            @Override//  ww  w  . j  av a  2 s .c o m
            public void onBlur(BlurEvent event) {
                InputDatePicker.this.hide();
            }
        });
    }
}