Example usage for com.google.gwt.user.client.ui Widget setStyleName

List of usage examples for com.google.gwt.user.client.ui Widget setStyleName

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget setStyleName.

Prototype

public void setStyleName(String style) 

Source Link

Document

Clears all of the object's style names and sets it to the given style.

Usage

From source file:pl.balon.gwt.diagramsexample.client.examples.DiagramBuilderExample.java

License:Apache License

private Widget createToolboxNode(String label, String style) {
    Widget node = new Label(label);
    node.setStyleName("toolbox-node");
    node.addStyleName(style);/*from   w ww. ja va 2  s.  c  om*/
    toolbox.add(node);
    toolboxDragController.makeDraggable(node);
    return node;
}

From source file:rocket.dragndrop.client.DraggablePanel.java

License:Apache License

/**
 * This event is fired whenever a user starts a drag of a draggable widget.
 * //from   w ww .  j  a v a 2  s  .  co  m
 * @param mouseDownEvent
 */
protected void onDragStart(final MouseDownEvent mouseDownEvent) {
    Checker.notNull("parameter:mouseDownEvent", mouseDownEvent);

    while (true) {
        // first disable / clear any selections...
        Selection.disableTextSelection();
        Selection.clearAnySelectedText();

        mouseDownEvent.stop();

        // fire the event...
        Widget dragged = createDraggedWidget();
        dragged.setStyleName(this.getGhostStyle());

        final DragStartEvent dragStartEvent = new DragStartEvent();
        dragStartEvent.setDraggablePanel(this);
        dragStartEvent.setDragged(dragged);
        dragStartEvent.setDraggedElement(mouseDownEvent.getTarget());

        Widget widget = this.getWidget();
        final Element widgetElement = widget.getElement();
        final int widgetLeft = widgetElement.getAbsoluteLeft();
        final int widgetTop = widgetElement.getAbsoluteTop();
        dragStartEvent.setWidget(widget);

        final int mouseLeft = mouseDownEvent.getPageX();
        final int mouseTop = mouseDownEvent.getPageY();
        dragStartEvent.setMousePageX(mouseLeft);
        dragStartEvent.setMousePageY(mouseTop);

        int xOffset = widgetLeft - mouseLeft;
        int yOffset = widgetTop - mouseTop;
        dragStartEvent.setXOffset(xOffset);
        dragStartEvent.setYOffset(yOffset);

        this.getDragNDropListeners().fireDragStarted(dragStartEvent);

        // if cancelled good bye!
        if (dragStartEvent.isCancelled()) {
            break;
        }

        // update ui ( dragged widget etc )
        dragged = dragStartEvent.getDragged();
        xOffset = dragStartEvent.getXOffset();
        yOffset = dragStartEvent.getYOffset();
        widget = dragStartEvent.getWidget();

        final DraggedPanel draggedPanel = this.createDraggedPanel();
        draggedPanel.prepare(widget);
        draggedPanel.setWidget(dragged);
        draggedPanel.setXOffset(xOffset);
        draggedPanel.setYOffset(yOffset);
        draggedPanel.setActualWidget(widget);

        // register an event previewer to handle mouse events(watch for drag
        // move, drop ).
        final EventPreviewAdapter greedy = new EventPreviewAdapter() {
            public void onMouseMove(final MouseMoveEvent event) {
                DraggablePanel.this.onDragMove(event, draggedPanel);
            }

            public void onMouseUp(final MouseUpEvent event) {
                DraggablePanel.this.onDropped(event, draggedPanel, this);
            }
        };
        greedy.install();

        final Element dragPanelElement = draggedPanel.getElement();
        final int elementPageX = dragPanelElement.getAbsoluteLeft();
        final int elementPageY = dragPanelElement.getAbsoluteTop();

        // reposition the $dragged so it follows the mouse.
        final int mousePageX = mouseDownEvent.getPageX();
        final int mousePageY = mouseDownEvent.getPageY();
        dragStartEvent.setMousePageX(mousePageX);
        dragStartEvent.setMousePageY(mousePageY);

        final int newX = mousePageX + xOffset - elementPageX;
        final int newY = mousePageY + yOffset - elementPageY;

        final InlineStyle draggedInlineStyle = InlineStyle.getInlineStyle(dragged.getElement());
        draggedInlineStyle.setString(Css.POSITION, "absolute");
        draggedInlineStyle.setInteger(Css.LEFT, newX, CssUnit.PX);
        draggedInlineStyle.setInteger(Css.TOP, newY, CssUnit.PX);
        break;
    }
}

From source file:ru.fly.client.ui.panel.messagebox.MessageBox.java

License:Apache License

public MessageBox(String title, Widget w, List<Button> buttons) {
    super(DOM.createDiv());
    this.title = title;
    this.w = w;//from  w w  w . j  a va  2  s  .  c  o  m
    w.setStyleName(decor.css().inner());
    this.buttons = buttons;
    setStyleName(decor.css().mb());
    getStyle().setPosition(Style.Position.ABSOLUTE);
}

From source file:scrum.client.calendar.ADateSelectorWidget.java

License:Open Source License

@Override
protected final Widget onInitialization() {

    TableBuilder tb = ScrumGwt.createFieldTable();
    tb.add(new HyperlinkWidget(getAction()));

    List<SimpleEvent> events = getEvents();

    int eventCount = events.size();

    tb.nextRow();/*from w ww  .  ja  va2 s  . com*/
    Label eventLabel;
    if (eventCount > 0) {
        eventLabel = new Label("" + events.size());
    } else {
        eventLabel = new Label(" ");
    }

    eventLabel.setStyleName("DateSelectorWidget-events");
    tb.add(eventLabel);

    Widget panel = tb.createTable();

    if (isSelected()) {
        panel.setStyleName("DateSelectorWidget-selected");
    } else if (isVisibleInList()) {
        panel.setStyleName("DateSelectorWidget-visible");
    } else {
        panel.setStyleName("DateSelectorWidget");
    }

    if (isToday()) {
        panel.addStyleName("DateSelectorWidget-today");
    }
    return panel;
}

From source file:stroom.menubar.client.view.MenubarViewImpl.java

License:Apache License

@Override
public Widget asWidget() {
    final Widget widget = super.asWidget();
    widget.setStyleName("menuBar");
    widget.setWidth("100%");
    return widget;
}

From source file:tv.dyndns.kishibe.qmaclone.client.game.input.InputWidgetTato.java

License:Open Source License

@Override
public void onClick(ClickEvent event) {
    Widget sender = (Widget) event.getSource();
    if (sender == buttonOk) {
        StringBuilder answerSend = new StringBuilder();
        for (int i = 0; i < numberOfChoice; ++i) {
            if (selectedIndex.contains(i)) {
                if (answerSend.length() != 0) {
                    answerSend.append(Constant.DELIMITER_GENERAL);
                }/*  w  w w  .ja  v  a 2s.co  m*/
                answerSend.append(problem.shuffledChoices[i]);
            }
        }
        sendAnswer(answerSend.toString());

    } else {
        int clickedIndex = 0;
        for (; clickedIndex < problem.getNumberOfShuffledChoices(); ++clickedIndex) {
            if (sender == buttonChoice[clickedIndex]) {
                break;
            }
        }

        // ????
        if (selectedIndex.contains(clickedIndex)) {
            selectedIndex.remove(clickedIndex);
        } else {
            selectedIndex.add(clickedIndex);
        }

        StringBuilder buffer = new StringBuilder();
        for (int index : selectedIndex) {
            buffer.append(getLetter(DIGIT, index));
        }
        answerView.set(buffer.toString(), false);

        // ?
        playSound(Constant.SOUND_URL_BUTTON_PUSH);

        // ?
        if (isImage) {
            if (selectedIndex.contains(clickedIndex)) {
                sender.setStyleName(STYLE_NAME_IMAGE_SELECTED);
            } else {
                sender.setStyleName(STYLE_NAME_IMAGE);
            }
        } else {
            if (selectedIndex.contains(clickedIndex)) {
                sender.setStyleName(STYLE_NAME_SELECTED);
            } else {
                sender.setStyleName(STYLE_NAME);
            }
        }
    }
}