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

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

Introduction

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

Prototype

public void setMargin(double value, Unit unit) 

Source Link

Usage

From source file:org.opencms.ade.containerpage.client.CmsContainerpageDNDController.java

License:Open Source License

/**
 * Sets styles of helper elements, appends the to the drop target and puts them into a drag info bean.<p>
 * //  w  ww .  java2s . c  o m
 * @param dragHelper the drag helper element
 * @param placeholder the placeholder element
 * @param target the drop target
 * @param handler the drag and drop handler
 */
private void prepareDragInfo(Element dragHelper, Element placeholder, I_CmsDropTarget target,
        CmsDNDHandler handler) {

    target.getElement().appendChild(dragHelper);
    // preparing helper styles
    int width = CmsDomUtil.getCurrentStyleInt(dragHelper, CmsDomUtil.Style.width);
    Style style = dragHelper.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setMargin(0, Unit.PX);
    style.setWidth(width, Unit.PX);
    style.setZIndex(I_CmsLayoutBundle.INSTANCE.constants().css().zIndexDND());
    dragHelper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragging());
    dragHelper.addClassName(org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.INSTANCE.generalCss().shadow());
    if (!CmsDomUtil.hasBackgroundImage(dragHelper)) {
        dragHelper.getStyle().setBackgroundColor(CmsDomUtil.getEffectiveBackgroundColor(dragHelper));
    }
    if (!CmsDomUtil.hasBorder(dragHelper)) {
        dragHelper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragElementBorder());
    }
    style.setDisplay(Display.NONE);

    String positioning = CmsDomUtil.getCurrentStyle(target.getElement(),
            org.opencms.gwt.client.util.CmsDomUtil.Style.position);
    // set target relative, if not absolute or fixed
    if (!Position.ABSOLUTE.getCssName().equals(positioning)
            && !Position.FIXED.getCssName().equals(positioning)) {
        target.getElement().getStyle().setPosition(Position.RELATIVE);
    }
    setMinHeight(target);
    m_dragInfos.put(target, new DragInfo(dragHelper, placeholder, width - 15, handler.getCursorOffsetY()));
    handler.addTarget(target);

    // adding drag handle
    Element button = DOM.createDiv();
    button.appendChild((new Image(I_CmsImageBundle.INSTANCE.icons().moveIconActive())).getElement());
    button.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragHandle());
    dragHelper.appendChild(button);
}

From source file:org.opencms.ade.containerpage.client.ui.CmsContainerPageElement.java

License:Open Source License

/**
 * @see org.opencms.gwt.client.dnd.I_CmsDraggable#getDragHelper(org.opencms.gwt.client.dnd.I_CmsDropTarget)
 *///from   ww w  .  jav  a2  s. c om
public Element getDragHelper(I_CmsDropTarget target) {

    Element helper = CmsDomUtil.clone(getElement());
    target.getElement().appendChild(helper);
    // preparing helper styles
    String width = CmsDomUtil.getCurrentStyle(helper, CmsDomUtil.Style.width);
    Style style = helper.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setMargin(0, Unit.PX);
    style.setProperty(CmsDomUtil.Style.width.name(), width);
    style.setZIndex(I_CmsLayoutBundle.INSTANCE.constants().css().zIndexDND());
    helper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragging());
    helper.addClassName(org.opencms.gwt.client.ui.css.I_CmsLayoutBundle.INSTANCE.generalCss().shadow());
    if (!CmsDomUtil.hasBackground(helper)) {
        helper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragElementBackground());
    }

    if (!CmsDomUtil.hasBorder(helper)) {
        helper.addClassName(I_CmsLayoutBundle.INSTANCE.dragdropCss().dragElementBorder());
    }
    return helper;
}

From source file:org.opencms.gwt.client.ui.CmsPreviewDialog.java

License:Open Source License

/**
 * Initializes the locale selector if needed.<p>
 *
 * @param previewInfo the preview info//from w  ww  .  j a va 2s  .c o m
 */
private void initLocales(CmsPreviewInfo previewInfo) {

    if (m_localeSelect != null) {
        removeButton(m_localeSelect);
        m_localeSelect = null;
    }
    if (previewInfo.hasAdditionalLocales()) {
        m_localeSelect = new CmsSelectBox(previewInfo.getLocales());
        m_localeSelect.setFormValueAsString(previewInfo.getLocale());
        m_localeSelect.addValueChangeHandler(new ValueChangeHandler<String>() {

            public void onValueChange(ValueChangeEvent<String> event) {

                loadOtherLocale(event.getValue());
            }
        });
        Style style = m_localeSelect.getElement().getStyle();
        style.setWidth(SELECTBOX_WIDTH, Unit.PX);
        style.setFloat(com.google.gwt.dom.client.Style.Float.LEFT);
        style.setMargin(0, Unit.PX);
        m_localeSelect.truncate(TRUNCATION_PREFIX, SELECTBOX_WIDTH - 20);
        addButton(m_localeSelect);

    }
}

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

License:Open Source License

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

    // extract classes from metadata if present
    JsArrayString classes = JsArrayString.createArray().cast();
    if (metadata != null)
        classes = metadata.getClasses();

    String clazz = classes.length() > 0 ? classes.get(0) : "html";
    thumbnail_ = new ChunkOutputThumbnail(clazz, classes.length() > 1 ? classes.get(1) : "",
            new ChunkHtmlPreview(), ChunkOutputWidget.getEditorColors());

    // amend the URL to cause any contained widget to use the RStudio viewer
    // sizing policy
    if (url.indexOf('?') > 0)
        url += "&";
    else// w w  w .ja  v a  2  s.c  o m
        url += "?";
    url += "viewer_pane=1";

    frame_ = new ChunkOutputFrame();

    if (chunkOutputSize != ChunkOutputSize.Full) {
        content_ = new FixedRatioWidget(frame_, ChunkOutputUi.OUTPUT_ASPECT,
                ChunkOutputUi.MAX_HTMLWIDGET_WIDTH);
    } else {
        frame_.getElement().getStyle().setWidth(100, Unit.PCT);
        content_ = frame_;
    }

    frame_.loadUrlDelayed(url, 400, new Command() {
        @Override
        public void execute() {
            Element body = frame_.getDocument().getBody();
            Style bodyStyle = body.getStyle();

            bodyStyle.setPadding(0, Unit.PX);
            bodyStyle.setMargin(0, Unit.PX);

            onEditorThemeChanged(ChunkOutputWidget.getEditorColors());

            Timer frameFinishLoadTimer = new Timer() {
                @Override
                public void run() {
                    onRenderComplete.execute();
                }
            };

            frameFinishLoadTimer.schedule(100);
        };
    });

    afterRender_ = new Command() {
        @Override
        public void execute() {
            Element body = frame_.getDocument().getBody();

            Style bodyStyle = body.getStyle();

            bodyStyle.setPadding(0, Unit.PX);
            bodyStyle.setMargin(0, Unit.PX);

            if (themeColors_ != null) {
                bodyStyle.setColor(themeColors_.foreground);
            }
        }
    };

    frame_.runAfterRender(afterRender_);
}

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

License:Open Source License

@Override
public void showHtmlOutput(String url, NotebookHtmlMetadata metadata, int ordinal,
        final Command onRenderComplete) {
    // flush any queued errors
    initializeOutput(RmdChunkOutputUnit.TYPE_HTML);
    flushQueuedErrors();//from w  w w  .j a va2  s  . c  o  m

    // persist metadata
    metadata_.put(ordinal, metadata);

    final boolean knitrFigure = metadata.getSizingPolicyKnitrFigure();

    // amend the URL to cause any contained widget to use the RStudio viewer
    // sizing policy
    if (url.indexOf('?') > 0)
        url += "&";
    else
        url += "?";

    if (knitrFigure) {
        url += "viewer_pane=1";
    }

    final ChunkOutputFrame frame = new ChunkOutputFrame();

    if (chunkOutputSize_ == ChunkOutputSize.Default) {
        if (knitrFigure) {
            final FixedRatioWidget fixedFrame = new FixedRatioWidget(frame, ChunkOutputUi.OUTPUT_ASPECT,
                    ChunkOutputUi.MAX_HTMLWIDGET_WIDTH);

            addWithOrdinal(fixedFrame, ordinal);
        } else {
            // reduce size of html widget as much as possible and add scroll,
            // once it loads, we will adjust the height appropriately.
            frame.getElement().getStyle().setHeight(25, Unit.PX);
            frame.getElement().getStyle().setOverflow(Overflow.SCROLL);

            frame.getElement().getStyle().setWidth(100, Unit.PCT);
            addWithOrdinal(frame, ordinal);
        }
    } else if (chunkOutputSize_ == ChunkOutputSize.Full) {
        frame.getElement().getStyle().setPosition(Position.ABSOLUTE);
        frame.getElement().getStyle().setWidth(100, Unit.PCT);
        frame.getElement().getStyle().setHeight(100, Unit.PCT);

        addWithOrdinal(frame, ordinal);
    }

    Element body = frame.getDocument().getBody();
    Style bodyStyle = body.getStyle();

    bodyStyle.setPadding(0, Unit.PX);
    bodyStyle.setMargin(0, Unit.PX);

    frame.loadUrlDelayed(url, 250, new Command() {
        @Override
        public void execute() {
            onRenderComplete.execute();

            if (!knitrFigure) {
                int contentHeight = frame.getWindow().getDocument().getBody().getOffsetHeight();
                frame.getElement().getStyle().setHeight(contentHeight, Unit.PX);

                frame.getElement().getStyle().setOverflow(Overflow.HIDDEN);
                frame.getWindow().getDocument().getBody().getStyle().setOverflow(Overflow.HIDDEN);
            }

            onHeightChanged();
        };
    });

    themeColors_ = ChunkOutputWidget.getEditorColors();
    afterRender_ = new Command() {
        @Override
        public void execute() {
            if (themeColors_ != null) {
                Element body = frame.getDocument().getBody();

                Style bodyStyle = body.getStyle();
                bodyStyle.setColor(themeColors_.foreground);
            }
        }
    };

    frame.runAfterRender(afterRender_);
}

From source file:org.rstudio.studio.client.workbench.views.vcs.ConsoleProgressDialog.java

License:Open Source License

public ConsoleProgressDialog(String title, ConsoleProcess consoleProcess) {
    consoleProcess_ = consoleProcess;//from w ww . j  av a2s . c om

    setText(title);

    registrations_ = new HandlerRegistrations();
    registrations_.add(consoleProcess.addConsoleOutputHandler(this));
    registrations_.add(consoleProcess.addProcessExitHandler(this));

    output_ = new PreWidget();
    output_.getElement().getStyle().setMargin(0, Unit.PX);
    output_.getElement().getStyle().setFontSize(11, Unit.PX);

    scrollPanel_ = new BottomScrollPanel(output_);
    scrollPanel_.setSize("640px", "200px");

    Style style = scrollPanel_.getElement().getStyle();
    style.setBackgroundColor("white");
    style.setBorderStyle(BorderStyle.SOLID);
    style.setBorderColor("#BBB");
    style.setBorderWidth(1, Style.Unit.PX);
    style.setMargin(0, Unit.PX);
    style.setMarginBottom(3, Unit.PX);
    style.setPadding(4, Unit.PX);

    status_ = new Label("The process is executing...");

    button_ = new ThemedButton("Stop", this);
    addOkButton(button_);

    consoleProcess.start(new SimpleRequestCallback<Void>() {
        @Override
        public void onError(ServerError error) {
            // Show error and stop
            super.onError(error);
            closeDialog();
        }
    });
}

From source file:org.vaadin.sasha.portallayout.client.dnd.MouseDragHandler.java

License:Apache License

private void initCapturingWidget() {
    capturingWidget = new FocusPanel();
    capturingWidget.addMouseMoveHandler(this);
    capturingWidget.addMouseUpHandler(this);
    capturingWidget.addTouchMoveHandler(this);
    capturingWidget.addTouchEndHandler(this);
    capturingWidget.addTouchCancelHandler(this);
    Style style = capturingWidget.getElement().getStyle();
    // workaround for IE8 opacity
    // http://code.google.com/p/google-web-toolkit/issues/detail?id=5538
    style.setProperty("filter", "alpha(opacity=0)");
    style.setOpacity(0);// ww w.  jav  a2s  . co m
    style.setZIndex(1000);
    style.setMargin(0, Style.Unit.PX);
    style.setBorderStyle(BorderStyle.NONE);
    style.setBackgroundColor("blue");
}

From source file:stroom.dashboard.client.vis.VisFrame.java

License:Apache License

public VisFrame() {
    super("vis.html");// + "?time=" + System.currentTimeMillis());

    final Style style = getElement().getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(0, Unit.PX);/*  w  ww  .  j a  v a2s.  c  om*/
    style.setRight(0, Unit.PX);
    style.setTop(0, Unit.PX);
    style.setBottom(0, Unit.PX);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
    style.setMargin(0, Unit.PX);
    style.setPadding(0, Unit.PX);
    style.setBorderWidth(0, Unit.PX);

    messageSupport = new MessageSupport(getElement());
}