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:jetbrains.jetpad.projectional.domUtil.DomTextEditor.java

License:Apache License

private void updateCaretAndSelection() {
    Style caretStyle = myCaretDiv.getStyle();
    updateCaretPosition();/*from   w  w w .  j a va  2 s.  c o m*/
    caretStyle.setTop(0, Style.Unit.PX);
    caretStyle.setWidth(1, Style.Unit.PX);
    caretStyle.setHeight(getLineHeight(), Style.Unit.PX);
    caretStyle.setBackgroundColor("black");

    Style selectionStyle = mySelectionDiv.getStyle();
    selectionStyle.setTop(0, Style.Unit.PX);
    selectionStyle.setHeight(getLineHeight(), Style.Unit.PX);
    selectionStyle.setBackgroundColor("Highlight");
    selectionStyle.setColor("HighlightText");

    updateSelectionBoundsAndText();
}

From source file:jetbrains.jetpad.projectional.view.toGwt.BaseViewMapper.java

License:Apache License

@Override
protected void registerSynchronizers(SynchronizersConfiguration conf) {
    super.registerSynchronizers(conf);

    Style targetStyle = getTarget().getStyle();

    if (!isDomPosition()) {
        targetStyle.setPosition(Style.Position.ABSOLUTE);
    } else {//  w w  w .ja  v a  2  s  . c o  m
        targetStyle.setPosition(Style.Position.RELATIVE);
    }

    if (!isDomPosition() || !isDomLayout()) {
        final ReadableProperty<Rectangle> positionInParent;
        if (getParent() instanceof BaseViewMapper) {
            final BaseViewMapper<?, ?> parent = (BaseViewMapper<?, ?>) getParent();
            positionInParent = new DerivedProperty<Rectangle>(getSource().bounds(),
                    parent.getSource().bounds()) {
                @Override
                public Rectangle doGet() {
                    Rectangle sourceBounds = getSource().bounds().get();
                    Rectangle parentSourceBounds = parent.getSource().bounds().get();
                    return sourceBounds.sub(parentSourceBounds.origin);
                }
            };
        } else {
            positionInParent = getSource().bounds();
        }

        final Value<Boolean> valid = new Value<>(false);

        conf.add(Synchronizers.forEventSource(EventSources.composite(positionInParent, getSource().border()),
                new Runnable() {
                    @Override
                    public void run() {
                        valid.set(false);
                        whenValid(new Runnable() {
                            @Override
                            public void run() {
                                if (valid.get())
                                    return;
                                final Rectangle value = positionInParent.get();
                                Style style = getTarget().getStyle();

                                if (!isDomPosition()) {
                                    style.setLeft(value.origin.x, Style.Unit.PX);
                                    style.setTop(value.origin.y, Style.Unit.PX);
                                }

                                if (!isDomLayout()) {
                                    int width = value.dimension.x;
                                    int height = value.dimension.y;

                                    style.setWidth(width, Style.Unit.PX);
                                    style.setHeight(height, Style.Unit.PX);
                                }
                                valid.set(true);
                            }
                        });
                    }
                }));
    }

    if (!isCustomBackgroundSync()) {
        conf.add(Synchronizers.forPropsOneWay(getSource().background(), new WritableProperty<Color>() {
            @Override
            public void set(Color value) {
                Style style = getTarget().getStyle();
                if (value == null) {
                    style.setBackgroundColor(null);
                } else {
                    style.setBackgroundColor(value.toCssColor());
                }
            }
        }));
    }

    conf.add(Synchronizers.forPropsOneWay(getSource().border(), new WritableProperty<Color>() {
        @Override
        public void set(Color value) {
            Style style = getTarget().getStyle();
            if (value != null) {
                style.setOutlineColor(value.toCssColor());
                style.setOutlineWidth(1, Style.Unit.PX);
                style.setOutlineStyle(Style.OutlineStyle.SOLID);
            } else {
                style.clearOutlineStyle();
                style.clearOutlineColor();
                style.clearBorderWidth();
            }
        }
    }));

    conf.add(Synchronizers.forPropsOneWay(getSource().visible(), new WritableProperty<Boolean>() {
        @Override
        public void set(final Boolean value) {
            whenValid(new Runnable() {
                @Override
                public void run() {
                    getTarget().getStyle().setDisplay(value ? Style.Display.BLOCK : Style.Display.NONE);
                }
            });
        }
    }));

    conf.add(Synchronizers.forPropsOneWay(getSource().hasShadow(), new WritableProperty<Boolean>() {
        @Override
        public void set(Boolean value) {
            if (value) {
                getTarget().getStyle().setProperty("boxShadow", "2px 2px 4px black");
            } else {
                getTarget().getStyle().setProperty("boxShadow", null);
            }
        }
    }));
}

From source file:next.i.controller.Utils.java

License:Apache License

static void fillParent(Element elem) {
    Style style = elem.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(0, PX);/*from w ww . j  a  v  a  2  s.c  o m*/
    style.setTop(0, PX);
    style.setRight(0, PX);
    style.setBottom(0, PX);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
}

From source file:next.i.util.FxUtil.java

License:Apache License

public static void setStyleTop(Widget w, double top) {
    Style style = w.getElement().getStyle();
    style.setTop(top, Unit.PX);
}

From source file:nz.co.doltech.gwt.sdm.ui.SuperDevModeUI.java

License:Apache License

/**
 * Show the SuperDevModeUI message panel.
 * @param content the content to display.
 *///from  ww  w  . j a va2s . c  o  m
public void showMessagePanel(AbsolutePanel content) {
    PopupPanel popupPanel = new PopupPanel(true);
    popupPanel.addStyleName(resources.style().errorPanel());
    popupPanel.add(content);
    popupPanel.setAnimationEnabled(true);
    popupPanel.setGlassEnabled(true);
    sdmPanel.add(popupPanel);
    popupPanel.center();

    Style popupStyle = popupPanel.getElement().getStyle();
    double top = StyleUtil.getMeasurementValue(popupStyle.getTop());
    Unit unit = StyleUtil.getMeasurementUnit(popupStyle.getTop());
    popupStyle.setTop(top - 75, unit);

    popupPanel.show();
}

From source file:org.anstis.client.grid.widget.dom.BaseDOMElement.java

License:Apache License

/**
 * Transform the DOMElement based on the render context, such as scale and position.
 * @param context/*from   ww w.  ja v  a2  s . com*/
 */
protected void transform(final GridCellRenderContext context) {
    final Transform transform = context.getTransform();
    final double width = context.getWidth();
    final double height = context.getHeight();

    final Style style = container.getElement().getStyle();

    //Reposition and transform the DOM Element
    style.setLeft((context.getX() * transform.getScaleX()) + transform.getTranslateX(), Style.Unit.PX);
    style.setTop((context.getY() * transform.getScaleY()) + transform.getTranslateY(), Style.Unit.PX);
    style.setWidth(width, Style.Unit.PX);
    style.setHeight(height, Style.Unit.PX);

    if (isOne(transform.getScaleX()) && isOne(transform.getScaleY())) {
        style.clearProperty("WebkitTransform");
        style.clearProperty("MozTransform");
        style.clearProperty("Transform");
        return;
    }

    final String scale = "scale(" + FORMAT.format(transform.getScaleX()) + ", "
            + FORMAT.format(transform.getScaleY()) + ")";
    final String translate = "translate(" + FORMAT.format(((width - width * transform.getScaleX()) / -2.0))
            + "px, " + FORMAT.format(((height - height * transform.getScaleY()) / -2.0)) + "px)";
    style.setProperty("WebkitTransform", translate + " " + scale);
    style.setProperty("MozTransform", translate + " " + scale);
    style.setProperty("Transform", translate + " " + scale);
}

From source file:org.anstis.client.grid.widget.dom.CheckBoxDOMElement.java

License:Apache License

@Override
public void initialise(final IGridCell<Boolean> cell, final GridCellRenderContext context) {
    this.context = context;
    cb.setValue(cell == null ? false : cell.getValue().getValue());
    final Style style = cb.getElement().getStyle();
    style.setLeft((context.getWidth() - SIZE) / 2, Style.Unit.PX);
    style.setTop((context.getHeight() - SIZE) / 2, Style.Unit.PX);
    transform(context);//from  w w w.ja  v a  2  s  .  c om
}

From source file:org.cruxframework.crux.smartfaces.client.dialog.PopupPanel.java

License:Apache License

private void centralizeMe() {
    Style style = getElement().getStyle();
    style.setLeft(50, Unit.PCT);/* w  w  w.j ava2 s .  c  o m*/
    style.setTop(50, Unit.PCT);
    style.setProperty("webkitTransform", "translateY(-50%) translateX(-50%)");
    style.setProperty("transform", "translateY(-50%) translateX(-50%)");
    left = -1;
    top = -1;
    centered = true;
}

From source file:org.cruxframework.crux.widgets.client.slider.TouchSlider.java

License:Apache License

/**
 * /*from  ww  w  .  j  ava 2s .c o  m*/
 * @param contentProvider
 */
public void setContentProvider(ContentProvider contentProvider) {
    this.contentProvider = contentProvider;
    contentPanel.clear();
    for (int i = 0; i < contentProvider.size(); i++) {
        final int index = i;
        LazyPanel itemWrapper = new LazyPanel() {
            @Override
            protected Widget createWidget() {
                return TouchSlider.this.contentProvider.loadWidget(index);
            }
        };
        itemWrapper.setStyleName("touchSliderItem");
        itemWrapper.setVisible(false);
        Style style = itemWrapper.getElement().getStyle();
        style.setPosition(Position.ABSOLUTE);
        style.setTop(0, Unit.PX);
        style.setLeft(0, Unit.PX);
        style.setWidth(100, Unit.PCT);
        style.setHeight(100, Unit.PCT);
        style.setOverflowX(Overflow.HIDDEN);
        style.setOverflowY(Overflow.VISIBLE);
        contentPanel.add(itemWrapper);
    }

    if (this.circularShowing && contentProvider.size() < 3) {
        this.circularShowing = false;
    }
}

From source file:org.cruxframework.crux.widgets.client.slider.TouchSlider.java

License:Apache License

/**
 * //from   www.ja v a2s.c o  m
 * @param widget
 */
public void add(Widget widget) {
    SimplePanel itemWrapper = new SimplePanel();
    itemWrapper.add(widget);
    itemWrapper.setStyleName("touchSliderItem");
    itemWrapper.setVisible(false);
    Style style = itemWrapper.getElement().getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
    style.setOverflowX(Overflow.HIDDEN);
    style.setOverflowY(Overflow.VISIBLE);
    contentPanel.add(itemWrapper);
}