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:org.cruxframework.crux.widgets.client.uploader.FileButton.java

License:Apache License

public FileButton() {
    mainPanel = new FlowPanel();
    mainPanel.getElement().getStyle().setPosition(Position.RELATIVE);

    fileInput = new FileInput();

    Style style = fileInput.getElement().getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setTextAlign(TextAlign.RIGHT);
    style.setOpacity(0);/*w w  w .jav  a 2  s  . c  o m*/
    style.setProperty("cursor", "inherit");
    style.setZIndex(2);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    mainPanel.add(fileInput);

    visibleButton = new Label();
    visibleButton.setStyleName("chooseButton");
    style = visibleButton.getElement().getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setTop(0, Unit.PX);
    style.setLeft(0, Unit.PX);
    style.setZIndex(1);
    style.setWidth(100, Unit.PCT);
    style.setHeight(100, Unit.PCT);
    mainPanel.add(visibleButton);

    initWidget(mainPanel);
    setStyleName("crux-FileButton");
}

From source file:org.drools.workbench.screens.guided.dtable.client.widget.table.columns.dom.datepicker.DatePickerDOMElement.java

License:Apache License

public DatePickerDOMElement(final DatePicker widget, final GridLayer gridLayer, final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(HEIGHT, Style.Unit.PX);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);

    // --- Workaround for BS2 ---
    style.setPosition(Style.Position.RELATIVE);
    style.setPaddingTop(0, Style.Unit.PX);
    style.setPaddingBottom(0, Style.Unit.PX);
    style.setProperty("WebkitBoxSizing", "border-box");
    style.setProperty("MozBoxSizing", "border-box");
    style.setProperty("boxSizing", "border-box");
    style.setProperty("lineHeight", "normal");
    // --- End workaround ---

    getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX);
    getContainer().setWidget(widget);// w ww  .j  a v  a 2 s . c o m
}

From source file:org.drools.workbench.screens.scenariosimulation.client.domelements.CollectionEditorDOMElement.java

License:Apache License

/**
 *
 * @param widget//  w w  w. ja  va 2 s .  c o m
 * @param gridLayer
 * @param gridWidget
 */
public CollectionEditorDOMElement(final CollectionViewImpl widget, final GridLayer gridLayer,
        final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);
    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(100, Style.Unit.PCT);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setPaddingTop(2, Style.Unit.PX);
    style.setPaddingBottom(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);
    style.setProperty("resize", "none");

    final SimplePanel widgetContainer = getContainer();
    final Element widgetContainerElement = widgetContainer.getElement();
    final Style widgetContainerElementStyle = widgetContainerElement.getStyle();

    widgetContainerElementStyle.setPaddingLeft(5, Style.Unit.PX);
    widgetContainerElementStyle.setPaddingRight(5, Style.Unit.PX);
    widgetContainerElementStyle.setPaddingTop(5, Style.Unit.PX);
    widgetContainerElementStyle.setPaddingBottom(5, Style.Unit.PX);

    widgetContainer.setWidget(widget);
}

From source file:org.drools.workbench.screens.scenariosimulation.client.domelements.ScenarioCellTextAreaDOMElement.java

License:Apache License

public ScenarioCellTextAreaDOMElement(final TextArea widget, final GridLayer gridLayer,
        final GridWidget gridWidget) {
    super(widget, gridLayer, gridWidget);

    final Style style = widget.getElement().getStyle();
    style.setWidth(100, Style.Unit.PCT);
    style.setHeight(100, Style.Unit.PCT);
    style.setPaddingLeft(2, Style.Unit.PX);
    style.setPaddingRight(2, Style.Unit.PX);
    style.setPaddingTop(2, Style.Unit.PX);
    style.setPaddingBottom(2, Style.Unit.PX);
    style.setFontSize(10, Style.Unit.PX);
    style.setProperty("resize", "none");

    getContainer().getElement().getStyle().setPaddingLeft(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingRight(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingTop(5, Style.Unit.PX);
    getContainer().getElement().getStyle().setPaddingBottom(5, Style.Unit.PX);
    getContainer().setWidget(widget);/* w w w.  j a va  2  s  .  co  m*/
}

From source file:org.eclipse.che.ide.ext.java.client.documentation.QuickDocViewImpl.java

License:Open Source License

@Inject
public QuickDocViewImpl() {
    super(true, true);
    addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override// w w  w  .  j  a va2  s.  c  o m
        public void onClose(CloseEvent<PopupPanel> event) {
            if (delegate != null) {
                delegate.onCloseView();
            }
        }
    });

    setSize("400px", "200px");
    Style style = getElement().getStyle();
    style.setProperty("resize", "both");
    style.setPaddingBottom(0, Style.Unit.PX);
    style.setPaddingTop(3, Style.Unit.PX);
    style.setPaddingLeft(3, Style.Unit.PX);
    style.setPaddingRight(3, Style.Unit.PX);
    createFrame();
    add(frame);

}

From source file:org.eclipse.che.ide.part.widgets.partbutton.PartButtonWidget.java

License:Open Source License

/**
 * Creates a badge widget with a message
 *
 * @param messages/*from  www . ja v  a 2 s.  c  om*/
 *         messages count
 * @return new badge widget
 */
private Widget getBadge(int messages) {
    FlowPanel w = new FlowPanel();
    Style s = w.getElement().getStyle();

    s.setProperty("position", "absolute");
    s.setProperty("width", "12px");
    s.setProperty("height", "12px");

    s.setProperty("boxSizing", "border-box");
    s.setProperty("borderRadius", "8px");
    s.setProperty("textAlign", "center");

    s.setProperty("color", org.eclipse.che.ide.api.theme.Style.getBadgeFontColor());

    s.setProperty("left", "15px");
    s.setProperty("top", "3px");

    s.setProperty("borderWidth", "1.5px");
    s.setProperty("borderStyle", "solid");

    s.setProperty("fontFamily", "'Helvetica Neue', 'Myriad Pro', arial, Verdana, Verdana, sans-serif");
    s.setProperty("fontSize", "9.5px");
    s.setProperty("fontWeight", "bold");
    s.setProperty("textShadow", "none");

    s.setProperty("backgroundColor", org.eclipse.che.ide.api.theme.Style.getBadgeBackgroundColor());

    w.setStyleName("bounceOutUp");

    if (messages > 9) {
        s.setProperty("lineHeight", "5px");
        w.getElement().setInnerHTML("...");
    } else {
        s.setProperty("lineHeight", "10px");
        w.getElement().setInnerHTML("" + messages);
    }

    return w;
}

From source file:org.eclipse.swt.widgets.Control.java

License:Open Source License

/**
 * Sets the receiver's cursor to the cursor specified by the argument, or to
 * the default cursor for that kind of control if the argument is null.
 * <p>/*from ww w .jav a2 s  . com*/
 * When the mouse pointer passes over a control its appearance is changed to
 * match the control's cursor.
 * </p>
 * 
 * @param cursor
 *            the new cursor (or null)
 * 
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_INVALID_ARGUMENT - if the argument has been
 *                disposed</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 */
public void setCursor(Cursor c) {
    checkWidget();
    if (cursor != null && cursor.isDisposed())
        error(SWT.ERROR_INVALID_ARGUMENT);
    this.cursor = c;
    // setCursor(cursor != null ? cursor.handle : 0);

    com.google.gwt.user.client.ui.Widget widget = getGwtWidget();

    Element element = widget.getElement();

    Style style = element.getStyle();
    if (c == null) {
        style.setCursor(Style.Cursor.DEFAULT);
        return;
    }

    Image image = c.getImage();

    if (image != null) {
        com.google.gwt.user.client.ui.Image gwtImage = image.getGwtImage();
        if (gwtImage != null) {
            String bi = gwtImage.getElement().getStyle().getBackgroundImage();
            if (bi.isEmpty()) {
                bi = "url(" + gwtImage.getUrl() + ")";
            }
            style.setProperty("cursor", bi + ",auto");
            return;
        }

    }

    int type = c.getStyle();
    if (type == SWT.CURSOR_NO) {
        // this is a Microsoft style, not W3C
        style.setProperty("cursor", "not-allowed");
        return;
    }

    com.google.gwt.dom.client.Style.Cursor gwtCursor = Style.Cursor.DEFAULT;
    switch (type) {
    case SWT.CURSOR_ARROW:
        gwtCursor = Style.Cursor.POINTER;
        break;
    case SWT.CURSOR_SIZEN:
        gwtCursor = Style.Cursor.N_RESIZE;
        break;
    case SWT.CURSOR_SIZENE:
        gwtCursor = Style.Cursor.NE_RESIZE;
        break;
    case SWT.CURSOR_SIZEE:
        gwtCursor = Style.Cursor.E_RESIZE;
        break;
    case SWT.CURSOR_SIZES:
        gwtCursor = Style.Cursor.S_RESIZE;
        break;
    case SWT.CURSOR_SIZESW:
        gwtCursor = Style.Cursor.SW_RESIZE;
        break;
    case SWT.CURSOR_SIZEW:
        gwtCursor = Style.Cursor.W_RESIZE;
        break;
    case SWT.CURSOR_SIZENW:
        gwtCursor = Style.Cursor.NW_RESIZE;
        break;
    case SWT.CURSOR_SIZENS:
        gwtCursor = Style.Cursor.ROW_RESIZE;
        break;
    case SWT.CURSOR_SIZEWE:
        gwtCursor = Style.Cursor.COL_RESIZE;
        break;
    case SWT.CURSOR_CROSS:
        gwtCursor = Style.Cursor.CROSSHAIR;
        break;
    case SWT.CURSOR_HAND:
        break;
    case SWT.CURSOR_NO:
        // gwtCursor = Style.Cursor.SE_RESIZE;
        break;
    case SWT.CURSOR_SIZESE:
        gwtCursor = Style.Cursor.SE_RESIZE;
        break;
    case SWT.CURSOR_SIZEALL:
        gwtCursor = Style.Cursor.MOVE;
        break;
    case SWT.CURSOR_WAIT:
        gwtCursor = Style.Cursor.WAIT;
        break;
    }

    style.setCursor(gwtCursor);
}

From source file:org.eclipse.swt.widgets.Text.java

License:Open Source License

@Override
public void setBounds(int x, int y, int width, int height) {
    if (textArea.isAttached()) {
        textArea.setFocus(true);//from   w  w  w  . ja va  2  s .co m
        textArea.setText(getText());
        Style textAreaStyle = textArea.getElement().getStyle();
        textAreaStyle.setProperty("resize", "none");
        textAreaStyle.setBorderStyle(BorderStyle.NONE);
        panel.setWidgetLeftWidth(textArea, x - 6, Unit.PX, width + 5, Unit.PX);
        panel.setWidgetTopHeight(textArea, y - 6, Unit.PX, height + 7, Unit.PX);
        textAreaStyle.setWidth(width + 5, Unit.PX);
        textAreaStyle.setHeight(height + 7, Unit.PX);
    }
}

From source file:org.errai.samples.asyncdemo.client.local.AsyncClient.java

License:Apache License

public void onModuleLoad() {
    final HorizontalPanel hPanel = new HorizontalPanel();
    final Label messagesReceived = new Label("Messaged Received: ");
    final Label messagesReceivedVal = new Label();

    class Counter {
        int count = 0;

        public void increment() {
            messagesReceivedVal.setText(String.valueOf(++count));
        }/*w  w  w.j a v  a2s .  com*/
    }

    final Counter counter = new Counter();

    for (int i = 0; i < 7; i++) {
        final VerticalPanel panel = new VerticalPanel();

        final Button startStopButton = new Button("Start" + i);
        final TextBox resultBox = new TextBox();
        resultBox.setEnabled(false);

        final String receiverName = "RandomNumberReceiver" + i;

        final Style resultStyle = resultBox.getElement().getStyle();

        /**
         * Create a callback receiver to receive the data from the server.
         */
        final MessageCallback receiver = new MessageCallback() {
            public void callback(Message message) {
                counter.increment();
                Double value = message.get(Double.class, "Data");
                resultBox.setText(String.valueOf(value));

                if (value > 0.5d) {
                    resultStyle.setProperty("backgroundColor", "green");
                } else {
                    resultStyle.setProperty("backgroundColor", "red");
                }
            }
        };

        /**
         * Subscribe to the receiver using the recevierName.
         */
        ErraiBus.get().subscribe(receiverName, receiver);

        final int num = i;

        startStopButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                /**
                 * Send a message to Start/Stop the task on the server.
                 */
                MessageBuilder.createMessage().toSubject("AsyncService").command(startStopButton.getText())
                        .with(MessageParts.ReplyTo, receiverName).noErrorHandling().sendNowWith(ErraiBus.get());

                /**
                 * Flip-flop the value of the button every time it's pushed between 'Start' and 'Stop'
                 */
                startStopButton.setText(
                        ("Start" + num).equals(startStopButton.getText()) ? "Stop" + num : "Start" + num);
            }
        });

        panel.add(startStopButton);
        panel.add(resultBox);

        hPanel.add(panel);
    }

    final VerticalPanel outerPanel = new VerticalPanel();
    outerPanel.add(hPanel);

    final HorizontalPanel messageCounter = new HorizontalPanel();
    messageCounter.add(messagesReceived);
    messageCounter.add(messagesReceivedVal);

    outerPanel.add(messageCounter);

    RootPanel.get().add(outerPanel);
}

From source file:org.glom.web.client.ui.details.SingleLineText.java

License:Open Source License

public SingleLineText(final String text) {
    Widget dataWidget;//from  w ww . j  a va2s .  co m
    if (text.startsWith("http://") || text.startsWith("ftp://")) {
        dataWidget = new Anchor(text, text, "_blank");
        dataWidget.setStyleName("dataLink");
    } else if (text.startsWith("www.")) {
        dataWidget = new Anchor(text, "http://" + text, "_blank");
        dataWidget.setStyleName("dataLink");
    } else {
        final Label dataLabel = new Label();
        dataLabel.setText(text);
        dataWidget = dataLabel;
    }

    final Style style = dataWidget.getElement().getStyle();
    style.setOverflow(Overflow.HIDDEN);
    style.setProperty("textOverflow", "ellipsis");

    initWidget(dataWidget);
}