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:cc.alcina.framework.gwt.client.ClientNotificationsImpl.java

License:Apache License

@Override
public void showDialog(String captionHTML, Widget captionWidget, String msg, MessageType messageType,
        List<Button> extraButtons, String containerStyle) {
    ensureImages();/*  w w w.  jav a 2s.c  o  m*/
    HorizontalAlignmentConstant align = messageType == MessageType.ERROR ? HasHorizontalAlignment.ALIGN_LEFT
            : HasHorizontalAlignment.ALIGN_CENTER;
    if (dialogBox != null) {
        dialogBox.hide();
    }
    String title = CommonUtils.friendlyConstant(messageType);
    dialogBox = new GlassDialogBox();
    dialogBox.setAnimationEnabled(dialogAnimationEnabled);
    AbstractImagePrototype aip = null;
    String text = "";
    switch (messageType) {
    case INFO:
        aip = AbstractImagePrototype.create(images.info());
        text = "Information";
        break;
    case WARN:
        aip = AbstractImagePrototype.create(images.warning());
        text = "Warning";
        break;
    case ERROR:
        aip = AbstractImagePrototype.create(images.error());
        text = "Problem notification";
        break;
    }
    dialogBox.setText(text);
    FlexTable ft = new FlexTable();
    containerStyle = containerStyle != null ? containerStyle
            : (messageType == MessageType.ERROR || !CommonUtils.isNullOrEmpty(msg)) ? "medium" : "narrow";
    ft.setCellSpacing(4);
    ft.setStyleName("alcina-Notification");
    ft.addStyleName(containerStyle);
    FlexCellFormatter cf = (FlexCellFormatter) ft.getCellFormatter();
    ft.setWidget(0, 0, aip.createImage());
    cf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    cf.setWidth(0, 0, "40px");
    FlowPanel fp = new FlowPanel();
    fp.setStyleName("text");
    Widget capWidget = captionHTML != null ? new HTML(captionHTML) : captionWidget;
    if (captionHTML != null) {
        capWidget.setStyleName("caption");
    }
    fp.add(capWidget);
    if (!CommonUtils.isNullOrEmpty(msg)) {
        Link nh = new Link("View detail");
        nh.addStyleName("pad-5");
        dialogHtml = new HTML("<span class='logboxpre'>" + msg.replace("\n", "<br>") + "</span>", true);
        final ScrollPanel sp = new ScrollPanel(dialogHtml);
        sp.setStyleName("logbox");
        sp.setVisible(containerStyle.equals("wide"));
        nh.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                sp.setVisible(!sp.isVisible());
            }
        });
        if (LooseContext.getBoolean(ClientNotifications.CONTEXT_AUTOSHOW_DIALOG_DETAIL)) {
            sp.setVisible(true);
        }
        fp.add(nh);
        fp.add(sp);
    }
    ft.setWidget(0, 1, fp);
    cf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(8);
    Button closeButton = new Button("Close");
    hp.add(closeButton);
    if (extraButtons != null) {
        for (Button b : extraButtons) {
            hp.add(b);
        }
    }
    ft.setWidget(1, 0, hp);
    cf.setColSpan(1, 0, 2);
    cf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogBox.setWidget(ft);
    dialogBox.center();
    dialogBox.show();
    Scheduler.get().scheduleDeferred(() -> closeButton.setFocus(true));
}

From source file:cc.alcina.framework.gwt.client.gwittir.widget.BoundTableExt.java

License:Open Source License

protected void addRow(final SourcesPropertyChangeEvents o) {
    int row = table.getRowCount();
    if (((((masks & BoundTableExt.HEADER_MASK) > 0) && (row >= 2))
            || (((masks & BoundTableExt.HEADER_MASK) == 0) && (row >= 1)))
            && ((masks & BoundTableExt.SPACER_ROW_MASK) > 0)) {
        table.setWidget(row, 0, new Label(""));
        table.getFlexCellFormatter().setColSpan(row, 0, this.columns.length);
        table.getRowFormatter().setStyleName(row, "spacer");
        row++;//w w w  . j  av a  2s.  c o  m
    }
    Binding bindingRow = new Binding();
    topBinding.getChildren().add(bindingRow);
    int count = topBinding.getChildren().size();
    final Widget handle;
    int startColumn = 0;
    if ((this.masks & BoundTableExt.ROW_HANDLE_MASK) > 0) {
        if ((this.masks & BoundTableExt.HANDLES_AS_CHECKBOXES) > 0) {
            handle = new Checkbox();
        } else {
            handle = new Button(
                    (this.getActive() && (rowHandles.size() < 9)) ? Integer.toString(this.rowHandles.size() + 1)
                            : " ");
        }
        handle.setStyleName("rowHandle");
        ((HasFocus) handle).addFocusListener(new FocusListener() {
            public void onFocus(Widget sender) {
                if (shiftDown) {
                    return;
                }
                setActive(true);
                List newSelected = null;
                if ((masks & BoundTableExt.MULTIROWSELECT_MASK) > 0) {
                    newSelected = new ArrayList(getSelected());
                    if (newSelected.contains(o)) {
                        newSelected.remove(o);
                    } else {
                        newSelected.add(o);
                    }
                } else {
                    newSelected = new ArrayList();
                    newSelected.add(o);
                }
                setSelected(newSelected);
            }

            public void onLostFocus(Widget sender) {
            }
        });
        ((SourcesClickEvents) handle).addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                setActive(true);
                List newSelected = null;
                if ((masks & BoundTableExt.MULTIROWSELECT_MASK) > 0) {
                    newSelected = new ArrayList(getSelected());
                    if (newSelected.contains(o)) {
                        newSelected.remove(o);
                    } else {
                        newSelected.add(o);
                    }
                } else {
                    newSelected = new ArrayList();
                    newSelected.add(o);
                }
                if (handle != null) {
                    ((HasFocus) handle).setFocus(true);
                }
                if (handle != null) {
                    ((HasFocus) handle).setFocus(true);
                }
                setSelected(newSelected);
            }
        });
        startColumn++;
        this.rowHandles.add(handle);
        this.table.setWidget(row, 0, handle);
    } else {
        handle = null;
    }
    if (count < 10) {
        SuggestedKeyBinding kb = new SuggestedKeyBinding(Integer.toString(count).charAt(0), false, true, false);
        Task task = new Task() {
            public void run() {
                List newSelected = new ArrayList(getSelected());
                if (newSelected.contains(o)) {
                    newSelected.remove(o);
                } else {
                    newSelected.add(o);
                }
                setSelected(newSelected);
                if (handle != null) {
                    ((HasFocus) handle).setFocus(true);
                }
            }
        };
        this.keyBindings.put(kb, task);
        if (this.getActive()) {
            try {
                KeyboardController.INSTANCE.register(kb, task);
            } catch (KeyBindingException kbe) {
                BoundTableExt.LOG.log(Level.DEBUG, "Unable to register" + kb, kbe);
            }
        }
    }
    for (int col = 0; col < this.columns.length; col++) {
        Widget widget = (Widget) createCellWidget(bindingRow, col, o);
        try {
            table.setWidget(row, col + startColumn, widget);
            if (widget instanceof HasFocus) {
                addSelectedFocusListener((HasFocus) widget, topBinding.getChildren().size() - 1,
                        col + startColumn);
            }
            if (widget instanceof SourcesClickEvents) {
                addSelectedClickListener((SourcesClickEvents) widget, topBinding.getChildren().size() - 1,
                        col + startColumn);
            }
            if (this.columns[col].getWidgetStyleName() != null) {
                widget.addStyleName(this.columns[col].getWidgetStyleName());
            }
            if (this.columns[col].getStyleName() != null) {
                table.getCellFormatter().setStyleName(row, col + startColumn, this.columns[col].getStyleName());
            }
        } catch (RuntimeException e) {
            BoundTableExt.LOG.log(Level.ERROR, widget + "", e);
        }
    }
    if ((this.masks & BoundTableExt.END_ROW_BUTTON) > 0) {
        EndRowButton endRowButton = new EndRowButton();
        table.setWidget(row, this.columns.length + startColumn, endRowButton);
        int f_row = row;
        endRowButton.addClickHandler(e -> {
            EndRowButtonClickedEvent.fire(BoundTableExt.this, f_row, o);
        });
    }
    if (collectionPropertyChangeListener != null) {
        o.addPropertyChangeListener(collectionPropertyChangeListener);
        listenedToByCollectionChangeListener.add(o);
    }
    boolean odd = (this.calculateRowToObjectOffset(new Integer(row)).intValue() % 2) != 0;
    this.table.getRowFormatter().setStyleName(row, odd ? "odd" : "even");
    bindingRow.setLeft();
}

From source file:ch.sebastienzurfluh.swissmuseum.parcours.client.view.infos.InfoPanel.java

License:Open Source License

public void setContent(Widget content) {
    content.setStyleName("infoPanel-content");
    contentPanel.setWidget(content);
}

From source file:com.alkacon.acacia.client.ui.AttributeChoiceWidget.java

License:Open Source License

/**
 * Adds a choice to the widget.<p>
 * //  ww  w  .j  av  a 2s. c  o m
 * @param choice the choice to add
 */
public void addChoice(Widget choice) {

    choice.setStyleName(I_LayoutBundle.INSTANCE.attributeChoice().choice());
    m_choices.add(choice);
}

From source file:com.allen_sauer.gwt.dnd.demo.client.example.palette.PaletteWidget.java

License:Apache License

public PaletteWidget cloneWidget() {
    Widget clone;

    // Clone our internal widget
    if (widget instanceof Label) {
        Label label = (Label) widget;
        clone = new Label(label.getText());
    } else if (widget instanceof RadioButton) {
        RadioButton radioButton = (RadioButton) widget;
        clone = new RadioButton(radioButton.getName(), radioButton.getHTML(), true);
    } else if (widget instanceof CheckBox) {
        CheckBox checkBox = (CheckBox) widget;
        clone = new CheckBox(checkBox.getHTML(), true);
    } else {/*  w  ww  .  j a  v a 2 s  . co  m*/
        throw new IllegalStateException("Unhandled Widget class " + widget.getClass().getName());
    }

    // Copy a few obvious common widget properties
    clone.setStyleName(widget.getStyleName());
    clone.setTitle(widget.getTitle());

    // Wrap the cloned widget in a new PaletteWidget instance
    return new PaletteWidget(clone);
}

From source file:com.cms.gwt.fs.client.view.calendar.ExtMultiView.java

License:Apache License

public void setSelected(RoundedPanel label, Label button) {
    for (int i = 0; i < items.size(); i++) {
        final Widget wi = items.get(i);
        if (wi instanceof RoundedPanel) {
            final RoundedPanel real = (RoundedPanel) wi;
            real.setCornerStyleName(FtrGwtDateCss.TAB);
        } else {/*from  w w w .  j  a  v a  2 s  .  c o  m*/
            wi.setStyleName(FtrGwtDateCss.TAB_BODY);
        }
    }
    label.setCornerStyleName(FtrGwtDateCss.TAB_SELECTED);
    button.setStyleName(FtrGwtDateCss.TAB_SELECTED_BODY);
}

From source file:com.dianaui.universal.core.client.ui.ListDropDown.java

License:Apache License

@Override
public void add(final Widget child) {
    if (child instanceof AbstractToggleButton) {
        if (!(child instanceof AnchorButton)) {
            throw new IllegalArgumentException(
                    "Only buttons of type AnchorButton can be added to ListDropDown");
        }//  w  w w. j av a  2s .c  o m

        child.setStyleName(Styles.DROPDOWN_TOGGLE);
    }

    add(child, (Element) getElement());
}

From source file:com.dimdim.conference.ui.panels.client.StopRecordingFormWidget.java

License:Open Source License

private void addField(Widget w1, Widget w2, String w1Width, String w2Width) {
    HorizontalPanel hp1 = new HorizontalPanel();
    w1.setStyleName("common-text");
    hp1.add(w1);/*w  w w. ja  va  2s  .c  om*/
    hp1.setCellWidth(w1, w1Width);
    if (w2 != null) {
        w2.setStyleName("common-text");
        hp1.add(w2);
        hp1.setCellWidth(w2, w2Width);
    }
    this.add(hp1);
    this.setCellWidth(hp1, "100%");
}

From source file:com.edgenius.wiki.gwt.client.BaseEntryPoint.java

License:Open Source License

public void addBeforeNav(Widget widget) {
    widget.setStyleName(Css.LEFT);
    navMainPanel.add(widget, navID0);
}

From source file:com.edgenius.wiki.gwt.client.widgets.ButtonBar.java

License:Open Source License

public void add(Widget btn) {

    super.add(btn);

    if ((style & ButtonBar.NORMAL) > 0) {
        btn.setStyleName(null);
    } else if ((style & ButtonBar.NEGATIVE) > 0) {
        btn.setStyleName(Css.NEGATIVE);/*  w  ww.  j  av  a2s .  c  om*/
    } else {
        btn.setStyleName(Css.POSITIVE);
    }
}