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

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

Introduction

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

Prototype

public void setCursor(Cursor value) 

Source Link

Usage

From source file:com.googlesource.gerrit.plugins.labelui.client.LabelPanel.java

License:Apache License

private static Label createLabelLabel(LabelInfo label) {
    Label l = new Label(label.name());
    Style s = l.getElement().getStyle();
    s.setCursor(Cursor.DEFAULT);
    if (label.rejected() != null) {
        s.setColor(COLOR_RED);// ww w .j ava 2  s . co  m
        l.setTitle("Rejected by " + label.rejected().name());
    } else if (label.approved() != null) {
        s.setColor(COLOR_GREEN);
        l.setTitle("Approved by " + label.approved().name());
    }
    return l;
}

From source file:com.googlesource.gerrit.plugins.labelui.client.LabelPanel.java

License:Apache License

public static Label createValueLabel(String formattedValue, String valueText, short value) {
    Label l = new Label(formattedValue);
    if (valueText != null) {
        l.setTitle(valueText);/*from   w  w  w . j  av  a2s .  com*/
    }
    Style s = l.getElement().getStyle();
    s.setTextAlign(TextAlign.CENTER);
    s.setCursor(Cursor.DEFAULT);
    if (value > 0) {
        s.setColor(COLOR_GREEN);
    } else if (value < 0) {
        s.setColor(COLOR_RED);
    } else {
        // make label invisible, we cannot omit it since we need the label to show
        // a tooltip
        s.setColor("transparent");
    }
    return l;
}

From source file:com.ksyzt.gwt.client.ui.richeditor.RichTextToolbar.java

License:Open Source License

/**
 *  Method to create the colorlist for the toolbar *.
 *
 * @return the color label//from  w  w  w  .ja  va 2  s  . c  o m
 */
private ColorLabel createColorList() {

    colorlist = new ColorLabel();
    Style style = colorlist.getElement().getStyle();

    style.setDisplay(Display.BLOCK);
    style.setPropertyPx("lineHeight", 14);
    style.setCursor(Cursor.POINTER);
    colorlist.setWidth("60px");

    colorlist.addMessageHandler(m_color_handler);
    return colorlist;
}

From source file:com.vaadin.client.SimpleTree.java

License:Apache License

public SimpleTree() {
    setElement(Document.get().createDivElement());
    Style style = getElement().getStyle();
    style.setProperty("whiteSpace", "nowrap");
    style.setPadding(3, Unit.PX);/*from  w w w  .  ja  v  a 2s .c  om*/
    style.setPaddingLeft(12, Unit.PX);
    // handle styling
    style = handle.getStyle();
    style.setDisplay(Display.NONE);
    style.setTextAlign(TextAlign.CENTER);
    style.setWidth(0.5, Unit.EM);
    style.setHeight(0.5, Unit.EM);
    style.setCursor(Cursor.POINTER);
    style.setBackgroundColor("gray");
    style.setColor("white");
    style.setPadding(4, Unit.PX);
    style.setMarginRight(3, Unit.PX);
    style.setLineHeight(0.5, Unit.EM);
    handle.setInnerHTML("+");
    getElement().appendChild(handle);
    getElement().appendChild(text);
    // children styling
    style = children.getStyle();
    style.setPaddingLeft(1.5, Unit.EM);
    style.setDisplay(Display.NONE);

    getElement().appendChild(children);
    addDomHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (event.getNativeEvent().getEventTarget().cast() == handle) {
                if (children.getStyle().getDisplay().intern() == Display.NONE.getCssName()) {
                    open(event.getNativeEvent().getAltKey());
                } else {
                    close();
                }

            } else if (event.getNativeEvent().getEventTarget().cast() == text) {
                select(event);
            }
        }
    }, ClickEvent.getType());
}

From source file:com.vaadin.terminal.gwt.client.SimpleTree.java

License:Open Source License

public SimpleTree() {
    setElement(Document.get().createDivElement());
    Style style = getElement().getStyle();
    style.setProperty("whiteSpace", "nowrap");
    style.setPadding(3, Unit.PX);//from   w  w w .ja  va2  s  .  co m

    style = handle.getStyle();
    style.setDisplay(Display.NONE);
    style.setProperty("textAlign", "center");
    style.setWidth(10, Unit.PX);
    style.setCursor(Cursor.POINTER);
    style.setBorderStyle(BorderStyle.SOLID);
    style.setBorderColor("#666");
    style.setBorderWidth(1, Unit.PX);
    style.setMarginRight(3, Unit.PX);
    style.setProperty("borderRadius", "4px");
    handle.setInnerHTML("+");
    getElement().appendChild(handle);
    getElement().appendChild(text);
    style = children.getStyle();
    style.setPaddingLeft(20, Unit.PX);
    style.setDisplay(Display.NONE);

    getElement().appendChild(children);
    addDomHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (event.getNativeEvent().getEventTarget().cast() == handle) {
                if (children.getStyle().getDisplay().intern() == Display.NONE.getCssName()) {
                    open(event.getNativeEvent().getShiftKey());
                } else {
                    close();
                }

            } else if (event.getNativeEvent().getEventTarget().cast() == text) {
                select(event);
            }
        }
    }, ClickEvent.getType());
}

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

License:Apache License

public BaseDOMElement(final GridLayer gridLayer, final BaseGridWidget<?, ?> gridWidget,
        final IDOMElementFactory<T, ?> factory, final AbsolutePanel domElementContainer) {
    this.gridLayer = gridLayer;
    this.gridWidget = gridWidget;
    this.factory = factory;
    this.domElementContainer = domElementContainer;

    final Style style = container.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.
    container.addDomHandler(new MouseDownHandler() {
        @Override//from w  w  w  .  j a  va 2 s.  c  o m
        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() + container.getElement().getOffsetLeft();
                }

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

            });
        }
    }, MouseDownEvent.getType());
    container.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() + container.getElement().getOffsetLeft();
                }

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

            });
        }
    }, MouseMoveEvent.getType());
    container.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() + container.getElement().getOffsetLeft();
                }

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

            });
        }
    }, MouseUpEvent.getType());
    container.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() + container.getElement().getOffsetLeft();
                }

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

            });
        }
    }, ClickEvent.getType());
}

From source file:org.dashbuilder.renderer.client.metric.MetricViewImpl.java

License:Apache License

@Override
public HandlerRegistration addClickHandler(ClickHandler clickHandler) {
    Style style = centerPanel.getElement().getStyle();
    style.setCursor(Style.Cursor.POINTER);
    return centerPanel.addClickHandler(clickHandler);
}

From source file:org.eclipse.che.ide.ext.git.client.action.StatusBarBranchPointer.java

License:Open Source License

@Override
public void update(ActionEvent e) {
    panel.clear();//  w  w w .  j ava 2s .  c  o  m

    Project project = appContext.getRootProject();
    if (project != null && project.getAttributes().containsKey(GIT_CURRENT_HEAD_NAME)) {
        Label projectNameLabel = new Label(project.getName());
        projectNameLabel.ensureDebugId("statusBarProjectBranchRepositoryName");
        projectNameLabel.getElement().getStyle().setMarginLeft(5., Unit.PX);
        panel.add(projectNameLabel);

        SVGImage branchIcon = new SVGImage(resources.checkoutReference());
        branchIcon.getSvgElement().getStyle().setMarginLeft(5., Unit.PX);
        panel.add(branchIcon);

        Label headLabel = new Label(project.getAttribute(GIT_CURRENT_HEAD_NAME));
        headLabel.ensureDebugId("statusBarProjectBranchName");
        headLabel.setTitle(constant.branchesControlTitle());
        Style headLabelStyle = headLabel.getElement().getStyle();
        headLabelStyle.setCursor(Cursor.POINTER);
        headLabelStyle.setMarginLeft(5., Unit.PX);
        headLabel.addClickHandler(event -> branchPresenter.showBranches(project));
        panel.add(headLabel);
    }
}

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>/*w  w  w  . j  av a 2 s . co m*/
 * 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.kie.workbench.common.stunner.client.widgets.canvas.view.CanvasView.java

License:Apache License

@Override
public AbstractCanvas.View setCursor(final AbstractCanvas.Cursors cursor) {
    Style style = panel.getElement().getStyle();
    switch (cursor) {
    case AUTO://from  w  w  w  .j a  v  a  2  s. com
        style.setCursor(Style.Cursor.AUTO);
        break;
    case MOVE:
        style.setCursor(Style.Cursor.MOVE);
        break;
    case TEXT:
        style.setCursor(Style.Cursor.TEXT);
        break;
    case POINTER:
        style.setCursor(Style.Cursor.POINTER);
        break;
    case NOT_ALLOWED:
        style.setProperty(CURSOR, CURSOR_NOT_ALLOWED);
        break;
    case WAIT:
        style.setCursor(Style.Cursor.WAIT);
        break;
    case CROSSHAIR:
        style.setCursor(Style.Cursor.CROSSHAIR);
        break;
    }
    return this;
}