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

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

Introduction

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

Prototype

public void setProperty(String name, String value) 

Source Link

Usage

From source file:jetbrains.jetpad.cell.toDom.BaseCellMapper.java

License:Apache License

private void applyBackground(String color, String underline) {
    Style style = getTarget().getStyle();
    if (color == null) {
        if (underline == null) {
            style.clearProperty(BACKGROUND);
        } else {//from w  w  w.ja v  a 2s .  c  o m
            style.setProperty(BACKGROUND, underline + UNDERLINE_SUFFIX);
        }
    } else {
        if (underline == null) {
            style.setProperty(BACKGROUND, color);
        } else {
            style.setProperty(BACKGROUND, underline + UNDERLINE_SUFFIX + " " + color);
        }
    }
}

From source file:jetbrains.jetpad.cell.toDom.ScrollCellMapper.java

License:Apache License

@Override
public void refreshProperties() {
    super.refreshProperties();

    Style style = getTarget().getStyle();
    Vector maxDim = getSource().maxDimension().get();
    style.setProperty("maxWidth", maxDim.x + "px");
    style.setProperty("maxHeight", maxDim.y + "px");

    Boolean scroll = getSource().scroll().get();
    style.setOverflow(scroll ? Style.Overflow.SCROLL : Style.Overflow.VISIBLE);
}

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

License:Apache License

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

    final Style style = getTarget().getStyle();
    conf.add(Synchronizers.forPropsOneWay(getSource().scroll(), new WritableProperty<Boolean>() {
        @Override//from ww  w. j a va  2s  .  c om
        public void set(Boolean value) {
            style.setOverflow(value ? Style.Overflow.HIDDEN : Style.Overflow.VISIBLE);
        }
    }));
    conf.add(Synchronizers.forPropsOneWay(getSource().maxDimension(), new WritableProperty<Vector>() {
        @Override
        public void set(Vector value) {
            style.setProperty("maxWidth", value.x + "px");
            style.setProperty("maxHeight", value.y + "px");
        }
    }));
}

From source file:net.sf.mmm.client.ui.gwt.widgets.richtext.FeatureBehaviorFontFamily.java

License:Apache License

/**
 * {@inheritDoc}/*  ww  w. j  av  a2  s  .  co m*/
 */
@Override
protected void applyFontSettings(String value, Style style) {

    style.setProperty("fontFamily", value);
}

From source file:next.celebs.controller.FavoritesController.java

License:Apache License

@Override
public IsWidget getViewContent() {
    FlowPanel panel = new FlowPanel() {
        @Override//from   w  w w  .j  a v a2 s  .  c o m
        protected void onLoad() {
            super.onLoad();
            this.clear();
            doGetPhotos(this);
        }

    };
    Style s = panel.getElement().getStyle();
    s.setProperty("backgroundColor", "#fff");
    s.setProperty("padding", "1em");

    return panel;
}

From source file:next.celebs.controller.PhotoDragController.java

License:Apache License

@Override
public IsWidget getViewContent() {

    Photo p = getPhoto();/*from w w w  . j ava2  s.  c o  m*/

    SimplePanel widg = new SimplePanel();
    Style s = widg.getElement().getStyle();

    widg.setWidth(p.getWidth() + "px");
    widg.setHeight(p.getHeight() + "px");
    s.setProperty("backgroundImage", "url(" + p.getUrl() + ")");
    s.setProperty("backgroundRepeat", "no-repeat");

    int h = p.getHeight();
    int w = p.getWidth();

    int ofh = getView().asWidget().getOffsetHeight();
    int ofw = Window.getClientWidth();

    if (h < ofh) {
        s.setProperty("marginTop", (ofh - h) / 2 + "px");
    }

    if (w < ofw) {
        s.setProperty("marginLeft", (ofw - w) / 2 + "px");
    }

    return widg;
}

From source file:next.celebs.controller.PhotosController.java

License:Apache License

@Override
public IsWidget getViewContent() {
    final FlowPanel panel = new FlowPanel();
    Style s = panel.getElement().getStyle();
    s.setProperty("backgroundColor", "#fff");
    s.setProperty("padding", "1em");

    final FlowPanel imageWrapper = new FlowPanel();

    final XRadioButtonGroup group = new XRadioButtonGroup();
    XRadioButton btn0 = new XRadioButton("Wallpaper", "Wallpaper");
    XRadioButton btn1 = new XRadioButton("Beach", "Beach");
    XRadioButton btn2 = new XRadioButton("Bride", "Bride");
    group.add(btn0, btn1, btn2);//from www.  ja  va2  s  .  c  o  m
    group.getElement().getStyle().setProperty("marginBottom", "1em");

    final String celebName = getTitle();

    group.addSelectionChangedHandler(new SelectionChangedHandler() {
        public void onSelectionChanged(SelectionChangedEvent e) {

            imageWrapper.clear();
            imageWrapper.removeFromParent();
            panel.add(imageWrapper);

            String selected = group.getCheckedWidget().getName();
            if (selected.equals("Beach")) {
                selected = "swimwear";
            }

            doGetPhotos(imageWrapper, celebName + " " + selected);
        }
    });

    panel.add(group);
    panel.add(imageWrapper);

    doGetPhotos(imageWrapper, celebName);

    return panel;
}

From source file:next.celebs.DemoUtils.java

License:Apache License

public static void openWiki(String source, final String url) {

    int h = Window.getClientHeight();
    int w = Window.getClientWidth();

    // mobile phone
    if (h + w < 1000) {
        openURL(url);/*  w ww .j  a  v  a 2 s.  c  o m*/

    } else {
        final Frame frame = new Frame(url);
        Style s = frame.getElement().getStyle();
        s.setProperty("width", "100%");
        s.setProperty("height", "100%");

        final XPopup popup = new XPopup();
        final XDragScrollView view = new XDragScrollView();
        view.add(frame);
        popup.setWidget(view);
        popup.setTop("35px");
        popup.setRight("5%");
        popup.setLeft("10%");
        popup.setBottom("10%");
        popup.show();
    }

}

From source file:next.celebs.XImageDiv.java

License:Apache License

public XImageDiv(String imagePath, String width, String height, String backgroundPosition) {
    panel = new SimplePanel();
    initWidget(panel);/*from   w w w  .  j a  va 2s. c  o  m*/
    setStyleName(XStyle.ximage.name());

    Style s = panel.getElement().getStyle();
    s.setProperty("backgroundImage", "url('" + imagePath + "')");
    s.setProperty("backgroundRepeat", "no-repeat");

    if (backgroundPosition != null) {
        s.setProperty("backgroundPosition", backgroundPosition);
    }
    if (width != null) {
        s.setProperty("width", width);
    }
    if (height != null) {
        s.setProperty("height", height);
    }
}

From source file:next.i.view.widgets.XButton.java

License:Apache License

private void XButton_(XButtonType buttonType, boolean iconOrientationLeft, String imageUrl,
        String imagePressedUrl) {
    _item = new FlexTable();
    _item.setCellPadding(0);/*from   ww  w.  j a  va  2s.c  o m*/
    _item.setCellSpacing(0);
    initWidget(_item);
    sinkEvents(Event.ONCLICK | Event.ONTOUCHCANCEL | Event.ONTOUCHEND | Event.ONTOUCHMOVE | Event.ONTOUCHSTART);

    setStyleName(XStyle.xbutton.name());

    _item.setHTML(0, 0, "&nbsp;");
    _item.setHTML(0, 1, "<div>&nbsp;</div>");

    FlexCellFormatter cf = _item.getFlexCellFormatter();
    cf.setStyleName(0, 0, "body");
    cf.setStyleName(0, 1, "right");

    cf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);

    if (buttonType == XButtonType.NavigationRed || buttonType == XButtonType.NavigationBlue
            || buttonType == XButtonType.NavigationBlack) {
        addStyleName(XButtonType.Navigation.css() + " " + buttonType.css());

    } else {
        addStyleName(buttonType.css());
    }

    if (buttonType == XButtonType.Image) {
        Style s = _item.getElement().getStyle();
        // TODO fix pressed state
        s.setProperty("backgroundImage", "url(" + imageUrl + ")");

        if (iconOrientationLeft) {
            s.setProperty("paddingLeft", "30px");
            s.setProperty("backgroundPosition", "left center");

        } else {
            s.setProperty("paddingRight", "30px");
            s.setProperty("backgroundPosition", "right center");
        }
    }
}