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:org.rstudio.core.client.widget.FullscreenPopupPanel.java

License:Open Source License

public FullscreenPopupPanel(Widget titleWidget, Widget mainWidget, int margin, boolean closeOnEscape) {
    super(false, false, closeOnEscape);

    NineUpBorder border = new NineUpBorder(RES, 32, 20, 17, 20);
    if (titleWidget != null)
        addTitleWidget(border, titleWidget);
    addCloseButton(border);//from   www .j  ava 2 s.co m
    border.setSize("100%", "100%");
    border.setFillColor("white");
    border.setWidget(mainWidget);
    setWidget(border);
    setGlassEnabled(true);

    Style popupStyle = getElement().getStyle();
    popupStyle.setZIndex(1001);
    popupStyle.setPosition(Style.Position.ABSOLUTE);
    popupStyle.setTop(margin, Unit.PX);
    popupStyle.setBottom(margin, Unit.PX);
    popupStyle.setLeft(margin, Unit.PX);
    popupStyle.setRight(margin, Unit.PX);

    Style contentStyle = ((Element) getElement().getFirstChild()).getStyle();
    contentStyle.setWidth(100, Unit.PCT);
    contentStyle.setHeight(100, Unit.PCT);
}

From source file:org.rstudio.core.client.widget.ModalDialogBase.java

License:Open Source License

protected ProgressIndicator addProgressIndicator(final boolean closeOnCompleted) {
    final SlideLabel label = new SlideLabel(true);
    Element labelEl = label.getElement();
    Style labelStyle = labelEl.getStyle();
    labelStyle.setPosition(Style.Position.ABSOLUTE);
    labelStyle.setLeft(0, Style.Unit.PX);
    labelStyle.setRight(0, Style.Unit.PX);
    labelStyle.setTop(-12, Style.Unit.PX);
    getWidget().getElement().getParentElement().appendChild(labelEl);

    return new ProgressIndicator() {
        public void onProgress(String message) {
            if (message == null) {
                label.setText("", true);
                if (showing_)
                    clearProgress();/*from   w  ww  .j a v  a  2 s.co m*/
            } else {
                label.setText(message, false);
                if (!showing_) {
                    enableControls(false);
                    label.show();
                    showing_ = true;
                }
            }
        }

        public void onCompleted() {
            clearProgress();
            if (closeOnCompleted)
                closeDialog();
        }

        public void onError(String message) {
            clearProgress();
            RStudioGinjector.INSTANCE.getGlobalDisplay().showErrorMessage("Error", message);
        }

        @Override
        public void clearProgress() {
            if (showing_) {
                enableControls(true);
                label.hide();
                showing_ = false;
            }

        }

        private boolean showing_;
    };
}

From source file:org.rstudio.studio.client.application.ui.impl.WebApplicationHeader.java

License:Open Source License

@Inject
public void initialize(final Commands commands, EventBus eventBus, GlobalDisplay globalDisplay,
        ThemeResources themeResources, final Session session, Provider<CodeSearch> pCodeSearch) {
    eventBus_ = eventBus;//from  w w  w.  j  a v a  2  s  . c  o  m
    globalDisplay_ = globalDisplay;

    // Use the outer panel to just aggregate the menu bar/account area,
    // with the logo. The logo can't be inside the HorizontalPanel because
    // it needs to overflow out of the top of the panel, and it was much
    // easier to do this with absolute positioning.
    outerPanel_ = new FlowPanel();
    outerPanel_.getElement().getStyle().setPosition(Position.RELATIVE);

    // large logo
    logoLarge_ = new Image(ThemeResources.INSTANCE.rstudio());
    ((ImageElement) logoLarge_.getElement().cast()).setAlt("RStudio");
    Style style = logoLarge_.getElement().getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setTop(5, Unit.PX);
    style.setLeft(18, Unit.PX);

    // small logo
    logoSmall_ = new Image(ThemeResources.INSTANCE.rstudio_small());
    ((ImageElement) logoSmall_.getElement().cast()).setAlt("RStudio");
    style = logoSmall_.getElement().getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setTop(5, Unit.PX);
    style.setLeft(18, Unit.PX);

    // header container
    headerBarPanel_ = new HorizontalPanel();
    headerBarPanel_.setStylePrimaryName(themeResources.themeStyles().header());
    headerBarPanel_.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    headerBarPanel_.setWidth("100%");

    if (BrowseCap.INSTANCE.suppressBrowserForwardBack())
        suppressBrowserForwardBack();

    // override Cmd+W keybaord shortcut for Chrome
    if (BrowseCap.isChrome()) {
        int modifiers = (BrowseCap.hasMetaKey() ? KeyboardShortcut.META : KeyboardShortcut.CTRL)
                | KeyboardShortcut.ALT;

        AppCommand closeSourceDoc = commands.closeSourceDoc();
        closeSourceDoc.setShortcut(new KeyboardShortcut(modifiers, 'W'));
        ShortcutManager.INSTANCE.register(modifiers, 'W', closeSourceDoc, "", "", "");
    }

    // main menu
    advertiseEditingShortcuts(globalDisplay, commands);
    WebMenuCallback menuCallback = new WebMenuCallback();
    commands.mainMenu(menuCallback);
    mainMenu_ = menuCallback.getMenu();
    mainMenu_.setAutoHideRedundantSeparators(false);
    fixup(mainMenu_);
    mainMenu_.addStyleName(themeResources.themeStyles().mainMenu());
    AppMenuBar.addSubMenuVisibleChangedHandler(new SubMenuVisibleChangedHandler() {
        public void onSubMenuVisibleChanged(SubMenuVisibleChangedEvent event) {
            // When submenus of the main menu appear, glass over any iframes
            // so that mouse clicks can make the menus disappear
            if (event.isVisible())
                eventBus_.fireEvent(new GlassVisibilityEvent(true));
            else
                eventBus_.fireEvent(new GlassVisibilityEvent(false));
        }
    });
    headerBarPanel_.add(mainMenu_);

    HTML spacer = new HTML();
    headerBarPanel_.add(spacer);
    headerBarPanel_.setCellWidth(spacer, "100%");

    // commands panel (no widgets added until after session init)
    headerBarCommandsPanel_ = new HorizontalPanel();
    headerBarPanel_.add(headerBarCommandsPanel_);
    headerBarPanel_.setCellHorizontalAlignment(headerBarCommandsPanel_, HorizontalPanel.ALIGN_RIGHT);

    eventBus.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {
        public void onSessionInit(SessionInitEvent sie) {
            SessionInfo sessionInfo = session.getSessionInfo();

            // only show the user identity if we are in server mode
            if (sessionInfo.getShowIdentity())
                initCommandsPanel(sessionInfo);

            // complete toolbar initialization
            toolbar_.completeInitialization(sessionInfo);

            // add project tools to main menu
            projectMenuButton_ = new ProjectPopupMenu(sessionInfo, commands).getToolbarButton();
            projectMenuButton_.addStyleName(ThemeStyles.INSTANCE.webHeaderBarCommandsProjectMenu());
            headerBarPanel_.add(projectMenuButton_);
            showProjectMenu(!toolbar_.isVisible());
        }
    });

    // create toolbar
    toolbar_ = new GlobalToolbar(commands, eventBus, pCodeSearch);
    toolbar_.addStyleName(themeResources.themeStyles().webGlobalToolbar());

    // initialize widget
    initWidget(outerPanel_);
}

From source file:org.rstudio.studio.client.workbench.views.presentation.zoom.PresentationZoomPopup.java

License:Open Source License

public static void show() {
    Label mainWidget = new Label("mainWidget");
    mainWidget.setSize("100%", "100%");

    LayoutPanel layoutPanel = new LayoutPanel();
    layoutPanel.setSize("100%", "100%");
    layoutPanel.add(mainWidget);/*www.  j ava  2  s .  co m*/
    layoutPanel.setWidgetLeftRight(mainWidget, 0, Unit.PX, 0, Unit.PX);
    layoutPanel.setWidgetTopBottom(mainWidget, 0, Unit.PX, 0, Unit.PX);

    ModalPopupPanel popup = new ModalPopupPanel(false, false, true);
    Resources res = GWT.<Resources>create(Resources.class);
    NineUpBorder border = new NineUpBorder(res, 32, 20, 17, 20);
    addCloseButton(popup, border);
    border.setSize("100%", "100%");
    border.setFillColor("white");
    border.setWidget(layoutPanel);
    popup.setWidget(border);
    popup.setGlassEnabled(true);

    Style popupStyle = popup.getElement().getStyle();
    popupStyle.setZIndex(1001);
    popupStyle.setPosition(Style.Position.ABSOLUTE);
    popupStyle.setTop(0, Unit.PX);
    popupStyle.setBottom(0, Unit.PX);
    popupStyle.setLeft(0, Unit.PX);
    popupStyle.setRight(0, Unit.PX);

    Style contentStyle = ((Element) popup.getElement().getFirstChild()).getStyle();
    contentStyle.setWidth(100, Unit.PCT);
    contentStyle.setHeight(100, Unit.PCT);

    popup.center();
}

From source file:org.rstudio.studio.client.workbench.views.source.editors.text.ChunkPlotPage.java

License:Open Source License

public ChunkPlotPage(final String url, NotebookPlotMetadata metadata, int ordinal,
        final Command onRenderComplete, ChunkOutputSize chunkOutputSize) {
    super(ordinal);

    thumbnail_ = new HTMLPanel("");

    if (ChunkPlotWidget.isFixedSizePlotUrl(url)) {
        final Image thumbnail = new Image();
        thumbnail_.add(thumbnail);//www .  j  a  v  a  2  s  .  co m
        thumbnail_.getElement().getStyle().setTextAlign(TextAlign.CENTER);

        plot_ = new ChunkPlotWidget(url, metadata, new Command() {
            @Override
            public void execute() {
                ImageElementEx plot = plot_.getElement().cast();
                ImageElementEx img = thumbnail.getElement().cast();
                if (plot.naturalHeight() < plot.naturalWidth()) {
                    img.getStyle().setProperty("width", "100%");
                    img.getStyle().setProperty("height", "auto");
                } else {
                    img.getStyle().setProperty("height", "100%");
                    img.getStyle().setProperty("width", "auto");
                }
                thumbnail.setUrl(url);
                onRenderComplete.execute();
            }
        }, chunkOutputSize);
    } else {
        // automatically expand non-fixed plots
        thumbnail_.add(new FixedRatioWidget(new Image(url), ChunkOutputUi.OUTPUT_ASPECT, 100));
        plot_ = new ChunkPlotWidget(url, metadata, onRenderComplete, chunkOutputSize);
    }

    // look for messages or warnings in metadata
    boolean hasMessages = false;
    boolean hasWarnings = false;
    if (metadata != null) {
        for (int i = 0; i < metadata.getConditions().length(); i++) {
            int condition = metadata.getConditions().get(i).getInt(0);
            if (condition == ChunkConditionBar.CONDITION_MESSAGE)
                hasMessages = true;
            else if (condition == ChunkConditionBar.CONDITION_WARNING)
                hasWarnings = true;
        }
    }

    if (hasMessages || hasWarnings) {
        Image condImage = new Image();
        if (hasWarnings)
            condImage.setResource(new ImageResource2x(ThemeResources.INSTANCE.warningSmall2x()));
        else if (hasMessages)
            condImage.setResource(new ImageResource2x(ThemeResources.INSTANCE.infoSmall2x()));
        condImage.setWidth("8px");
        condImage.setHeight("7px");
        Style style = condImage.getElement().getStyle();
        style.setPosition(Position.ABSOLUTE);
        style.setBottom(5, Unit.PX);
        style.setRight(5, Unit.PX);
        thumbnail_.add(condImage);
    }
}

From source file:org.thechiselgroup.choosel.protovis.client.ProtovisWidgetWithAnnotations.java

License:Apache License

protected Element addDescriptionElement(int topPx, int leftPx, String html, String cssClass) {

    Element div = DOM.createDiv();
    div.setInnerHTML(html);/*w  w  w .j a va  2 s .  co  m*/
    Style style = div.getStyle();
    style.setTop(topPx, Unit.PX);
    style.setLeft(leftPx, Unit.PX);
    style.setPosition(Position.ABSOLUTE);

    if (cssClass != null) {
        div.setClassName(cssClass);
    }

    getElement().appendChild(div);
    return div;
}

From source file:org.uberfire.client.util.Layouts.java

License:Apache License

/**
 * Sets the CSS on the given widget so it automatically fills the available space, rather than being sized based on
 * the amount of space required by its contents. This tends to be useful when building a UI that always fills the
 * available space on the screen, as most desktop application windows do.
 * <p>/*from w  w w. j  av a  2s  . co  m*/
 * To achieve this, the element is given relative positioning with top and left set to 0px and width and height set
 * to 100%. This makes the widget fill its nearest ancestor which has relative or absolute positioning. This
 * technique is compatible with GWT's LayoutPanel system. Note that, like LayoutPanels, this only works if the host
 * page is in standards mode (has a {@code <!DOCTYPE html>} header).
 * @param w the widget that should always fill its available space, rather than being sized to fit its contents.
 */
public static void setToFillParent(Widget w) {
    Element e = w.getElement();
    Style s = e.getStyle();
    s.setPosition(Position.RELATIVE);
    s.setTop(0.0, Unit.PX);
    s.setLeft(0.0, Unit.PX);
    s.setWidth(100.0, Unit.PCT);
    s.setHeight(100.0, Unit.PCT);
}

From source file:org.uberfire.ext.widgets.table.client.ResizableMovableHeader.java

License:Apache License

private static void setLine(final Style style, final int width, final int top, final int height,
        final String color) {
    style.setPosition(Position.ABSOLUTE);
    style.setTop(top, PX);//  w w w  .  j  a  va  2s  .  c om
    style.setHeight(height, PX);
    style.setWidth(width, PX);
    style.setBackgroundColor(color);
    style.setZIndex(Integer.MAX_VALUE);
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.BaseDOMElement.java

License:Apache License

public BaseDOMElement(final W widget, final GridLayer gridLayer, final GridWidget gridWidget) {
    this.widget = widget;
    this.gridLayer = gridLayer;
    this.gridWidget = gridWidget;
    this.domElementContainer = gridLayer.getDomElementContainer();

    final Style style = widgetContainer.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);

    //MouseEvents over absolutely positioned elements do not bubble through the DOM.
    //Consequentially Event Handlers on GridLayer do not receive notification of MouseMove
    //Events used during column resizing. Therefore we manually bubble events to GridLayer.
    widgetContainer.addDomHandler(new MouseDownHandler() {
        @Override//w ww .ja va  2 s.  c  om
        public void onMouseDown(final MouseDownEvent event) {
            gridLayer.onNodeMouseDown(new NodeMouseDownEvent(event) {

                @Override
                public int getX() {
                    //Adjust the x-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getX() + widgetContainer.getElement().getOffsetLeft();
                }

                @Override
                public int getY() {
                    //Adjust the y-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getY() + widgetContainer.getElement().getOffsetTop();
                }
            });
        }
    }, MouseDownEvent.getType());
    widgetContainer.addDomHandler(new MouseMoveHandler() {
        @Override
        public void onMouseMove(final MouseMoveEvent event) {
            //The DOM Element changes the Cursor, so set to the state determined by the MouseEvent Handlers on GridLayer
            style.setCursor(gridLayer.getGridWidgetHandlersState().getCursor());

            gridLayer.onNodeMouseMove(new NodeMouseMoveEvent(event) {

                @Override
                public int getX() {
                    //Adjust the x-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getX() + widgetContainer.getElement().getOffsetLeft();
                }

                @Override
                public int getY() {
                    //Adjust the y-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getY() + widgetContainer.getElement().getOffsetTop();
                }
            });
        }
    }, MouseMoveEvent.getType());
    widgetContainer.addDomHandler(new MouseUpHandler() {
        @Override
        public void onMouseUp(final MouseUpEvent event) {
            gridLayer.onNodeMouseUp(new NodeMouseUpEvent(event) {

                @Override
                public int getX() {
                    //Adjust the x-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getX() + widgetContainer.getElement().getOffsetLeft();
                }

                @Override
                public int getY() {
                    //Adjust the y-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getY() + widgetContainer.getElement().getOffsetTop();
                }
            });
        }
    }, MouseUpEvent.getType());
    widgetContainer.addDomHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            gridWidget.onNodeMouseClick(new NodeMouseClickEvent(event) {

                @Override
                public int getX() {
                    //Adjust the x-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getX() + widgetContainer.getElement().getOffsetLeft();
                }

                @Override
                public int getY() {
                    //Adjust the y-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                    return super.getY() + widgetContainer.getElement().getOffsetTop();
                }
            });
        }
    }, ClickEvent.getType());
}

From source file:org.uberfire.ext.wires.core.grids.client.widget.dom.impl.BaseDOMElement.java

License:Apache License

/**
 * Attach the DOMElement to the GWT container, if not already attached.
 *///from  w  ww.  j  a va 2 s .co  m
public void attach() {
    final Iterator<Widget> itr = domElementContainer.iterator();
    while (itr.hasNext()) {
        if (itr.next().equals(widgetContainer)) {
            return;
        }
    }
    //When an Element is detached it's Position configuration is cleared, so reset it
    final Style style = widgetContainer.getElement().getStyle();
    style.setPosition(Style.Position.ABSOLUTE);
    style.setProperty("WebkitUserSelect", "none");
    style.setProperty("MozUserSelect", "none");
    style.setProperty("MsUserSelect", "none");

    domElementContainer.add(widgetContainer);
}