Example usage for com.vaadin.ui Button setId

List of usage examples for com.vaadin.ui Button setId

Introduction

In this page you can find the example usage for com.vaadin.ui Button setId.

Prototype

@Override
    public void setId(String id) 

Source Link

Usage

From source file:org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons.java

License:Open Source License

private Object addDeleteCell(final Object itemId) {
    if (itemId instanceof TagIdName && noTagLabel.equals(((TagIdName) itemId).getName())) {
        return null;
    }/* w  w  w.j  a  v  a  2  s  .c  om*/

    final Button deleteButton = SPUIComponentProvider.getButton("", "", "", "", true, FontAwesome.TRASH_O,
            SPUIButtonStyleNoBorder.class);
    if (itemId instanceof TagIdName) {
        deleteButton.setId(UIComponentIdProvider.DELETE_TAG_ID + ((TagIdName) itemId).getName());
    } else {
        deleteButton.setId(UIComponentIdProvider.DELETE_TAG_ID + itemId.toString());
    }
    deleteButton.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_DELETE));
    deleteButton.addClickListener(this::addDeleteButtonClickListener);
    return deleteButton;
}

From source file:org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons.java

License:Open Source License

private Button addUpdateCell(final Object itemId) {
    if (itemId instanceof TagIdName && noTagLabel.equals(((TagIdName) itemId).getName())) {
        return null;
    }/*from   ww  w.j av a  2s.c  o  m*/

    final Button editButton = SPUIComponentProvider.getButton("", "", "", "", true, FontAwesome.EDIT,
            SPUIButtonStyleNoBorder.class);
    if (itemId instanceof TagIdName) {
        editButton.setId(UIComponentIdProvider.UPDATE_TAG_ID + ((TagIdName) itemId).getName());
    } else {
        editButton.setId(UIComponentIdProvider.UPDATE_TAG_ID + itemId.toString());
    }
    editButton.setDescription(SPUIDefinitions.EDIT);
    editButton.addClickListener(this::addEditButtonClickListener);
    return editButton;
}

From source file:org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons.java

License:Open Source License

private Button createFilterButton(final Long id, final String name, final String description,
        final String color, final Object itemId) {
    /**
     * No icon displayed for "NO TAG" button.
     *///from w  w w.  ja  va2  s  . c  om
    final Button button = SPUIComponentProvider.getButton("", name, description, "", false, null,
            SPUITagButtonStyle.class);
    button.setId(createButtonId(name));
    button.setCaptionAsHtml(true);
    if (id != null) {
        // Use button.getCaption() since the caption name is modified
        // according to the length
        // available in UI.
        button.setCaption(prepareFilterButtonCaption(button.getCaption(), color));
    }

    if (!StringUtils.isEmpty(description)) {
        button.setDescription(description);
    } else {
        button.setDescription(name);
    }
    button.setData(id == null ? SPUIDefinitions.NO_TAG_BUTTON_ID : itemId);

    return button;
}

From source file:org.eclipse.hawkbit.ui.common.table.AbstractTable.java

License:Open Source License

private Object createDeleteButton(final Object itemId) {
    final Button deleteButton = SPUIComponentProvider.getButton("", "", "", "", true, FontAwesome.TRASH_O,
            SPUIButtonStyleNoBorderWithIcon.class);
    final String id = getEntityId(itemId);
    deleteButton.setId("delete.entity." + id);
    deleteButton.setDescription(i18n.getMessage(UIMessageIdProvider.TOOLTIP_DELETE));
    deleteButton.addClickListener(this::addDeleteButtonClickListener);
    return deleteButton;
}

From source file:org.eclipse.hawkbit.ui.management.dstable.DistributionTable.java

License:Open Source License

private Button createPinBtn(final Object itemId) {

    final Item item = getContainerDataSource().getItem(itemId);
    final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();

    final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
    final DistributionSetIdName distributionSetIdName = new DistributionSetIdName((Long) itemId, name, version);

    final Button pinBtn = new Button();
    pinBtn.setIcon(FontAwesome.THUMB_TACK);
    pinBtn.setHeightUndefined();/*from w  w w. j  av a  2 s . c  o  m*/
    pinBtn.addStyleName(getPinStyle());
    pinBtn.setData(distributionSetIdName);
    pinBtn.setId(getPinButtonId(name, version));
    pinBtn.setImmediate(true);
    pinBtn.setDescription(getI18n().getMessage(UIMessageIdProvider.TOOLTIP_DISTRIBUTION_SET_PIN));
    return pinBtn;
}

From source file:org.eclipse.hawkbit.ui.management.targettable.TargetTable.java

License:Open Source License

private Button getTagetPinButton(final Object itemId) {
    final Button pinBtn = new Button();
    final String controllerId = (String) getContainerDataSource().getItem(itemId)
            .getItemProperty(SPUILabelDefinitions.VAR_CONT_ID).getValue();
    final TargetIdName pinnedTarget = new TargetIdName((Long) itemId, controllerId);
    final StringBuilder pinBtnStyle = new StringBuilder(ValoTheme.BUTTON_BORDERLESS_COLORED);
    pinBtnStyle.append(' ');
    pinBtnStyle.append(ValoTheme.BUTTON_SMALL);
    pinBtnStyle.append(' ');
    pinBtnStyle.append(ValoTheme.BUTTON_ICON_ONLY);
    pinBtn.setStyleName(pinBtnStyle.toString());
    pinBtn.setHeightUndefined();//from   ww  w . j  a v  a2 s .co m
    pinBtn.setData(pinnedTarget);
    pinBtn.setId(UIComponentIdProvider.TARGET_PIN_ICON + controllerId);
    pinBtn.addClickListener(this::addPinClickListener);
    pinBtn.setDescription(getI18n().getMessage(UIMessageIdProvider.TOOLTIP_TARGET_PIN));
    if (isPinned(pinnedTarget)) {
        pinBtn.addStyleName(TARGET_PINNED);
        targetPinned = Boolean.TRUE;
        targetPinnedBtn = pinBtn;
        getEventBus().publish(this, PinUnpinEvent.PIN_TARGET);
    }
    pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE);
    HawkbitCommonUtil.applyStatusLblStyle(this, pinBtn, itemId);
    return pinBtn;
}

From source file:org.eclipse.hawkbit.ui.management.targettag.filter.TargetFilterQueryButtons.java

License:Open Source License

private Button createFilterButton(final Long id, final String name, final Object itemId) {
    final Button button = SPUIComponentProvider.getButton("", name, name, "", false, null,
            SPUITagButtonStyle.class);
    button.addStyleName("custom-filter-button");
    button.setId(name);
    if (id != null) {
        button.setCaption(name);/*from w  ww . j a va  2s  .  c o m*/
    }
    button.setDescription(name);
    button.setData(itemId);
    button.addClickListener(event -> customTargetTagFilterButtonClick.processButtonClick(event));
    return button;
}

From source file:org.lucidj.browser.BrowserView.java

License:Apache License

private Button createButton(Layout parent, String id, Resource icon, String caption, int kc, int mk) {
    final Button new_button = new Button();

    if (caption != null) {
        new_button.setCaption(caption);
    }/*from   ww w .  ja v  a 2 s.  c  o  m*/
    new_button.setIcon(icon);
    new_button.addStyleName("tiny");
    new_button.addStyleName("toolbar");
    new_button.setId(id);

    new_button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            handle_button_click(new_button);
        }
    });

    parent.addComponent(new_button);

    if (kc != 0) {
        new_button.addShortcutListener(new AbstractField.FocusShortcut(new_button, kc, mk) {
            @Override
            public void handleAction(Object sender, Object target) {
                handle_button_click(new_button);
            }
        });
    }

    return (new_button);
}

From source file:org.lucidj.browser.BrowserView.java

License:Apache License

private void build_toolbar() {
    current_toolbar = new CssLayout();

    CssLayout local_toolbar = new CssLayout();
    current_toolbar.addComponent(local_toolbar);

    CssLayout navigation = new CssLayout();
    navigation.addStyleName("v-component-group");
    navigation.addStyleName("ui-toolbar-spacer");
    createButton(navigation, "prev-smartbox", FontAwesome.CHEVRON_LEFT, null, ShortcutAction.KeyCode.ARROW_UP,
            ShortcutAction.ModifierKey.CTRL);
    createButton(navigation, "next-smartbox", FontAwesome.CHEVRON_RIGHT, null,
            ShortcutAction.KeyCode.ARROW_DOWN, ShortcutAction.ModifierKey.CTRL);
    local_toolbar.addComponent(navigation);

    createButton(local_toolbar, "save", FontAwesome.SAVE).addStyleName("ui-toolbar-spacer");
    //        createButton (local_toolbar, "test", FontAwesome.MAGIC)
    //            .addStyleName("ui-toolbar-spacer");
    //        createButton (local_toolbar, "test2", FontAwesome.FLASK)
    //                .addStyleName("ui-toolbar-spacer");

    CssLayout edition = new CssLayout();
    edition.addStyleName("v-component-group");
    edition.addStyleName("ui-toolbar-spacer");
    createButton(edition, "undo-cell-edit", FontAwesome.UNDO, "Undo");
    createButton(edition, "redo-cell-edit", FontAwesome.REPEAT, null);
    createButton(edition, "delete-cell", FontAwesome.TRASH_O, null);
    local_toolbar.addComponent(edition);

    CssLayout view_controls = new CssLayout();
    view_controls.addStyleName("v-component-group");
    view_controls.addStyleName("ui-toolbar-spacer");
    createButton(view_controls, VM_NOTEBOOK,
            new ExternalResource("vaadin://~/Browser_libraries/notebook-view.png"));
    createButton(view_controls, VM_SINGLE, new ExternalResource("vaadin://~/Browser_libraries/single-view.png"),
            null, ShortcutAction.KeyCode.INSERT, ShortcutAction.ModifierKey.CTRL);
    local_toolbar.addComponent(view_controls);

    // TODO: CTRL+ENTER => RUN AND SKIP TO NEXT
    // TODO: SELECTION + SHIFT+ENTER => RUN ONLY SELECTED STATEMENTS

    final Button source_view = new Button();
    source_view.setId("output");
    source_view.addStyleName("ui-toolbar-spacer");
    source_view.setHtmlContentAllowed(true);
    String ico = "<path class=\"path1\" d=\"M1088 128h-64v-64c0-35.2-28.8-64-64-64h-896c-35.2 0-64 28.8-64 64v768c0 35.2 28.8 64 64 64h64v64c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64v-768c0-35.2-28.8-64-64-64zM128 192v640h-63.886c-0.040-0.034-0.082-0.076-0.114-0.116v-767.77c0.034-0.040 0.076-0.082 0.114-0.114h895.77c0.040 0.034 0.082 0.076 0.116 0.116v63.884h-768c-35.2 0-64 28.8-64 64v0zM1088 959.884c-0.034 0.040-0.076 0.082-0.116 0.116h-895.77c-0.040-0.034-0.082-0.076-0.114-0.116v-767.77c0.034-0.040 0.076-0.082 0.114-0.114h895.77c0.040 0.034 0.082 0.076 0.116 0.116v767.768z\"></path>\n"
            + "<path class=\"path2\" d=\"M960 352c0 53.020-42.98 96-96 96s-96-42.98-96-96 42.98-96 96-96 96 42.98 96 96z\"></path>\n"
            + "<path class=\"path3\" d=\"M1024 896h-768v-128l224-384 256 320h64l224-192z\"></path>";
    source_view.setCaption(/*from w  ww.ja v  a  2 s.com*/
            "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1152 1024\">"
                    + ico + "</svg>");
    source_view.addStyleName("tiny");
    source_view.addStyleName("toolbar");
    source_view.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            handle_button_click(source_view);
        }
    });
    local_toolbar.addComponent(source_view);

    //        Button output_view = new Button ();
    //        output_view.setHtmlContentAllowed(true);
    //        String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>";
    //        output_view.setCaption("<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico2 + "</svg>");
    //        output_view.addStyleName("tiny");
    //        view_controls.addComponent (output_view);
    //
    //        Button run = new Button ();
    //        run.setHtmlContentAllowed(true);
    //        String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>";
    //        run.setCaption("<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico3 + "</svg>");
    //        run.addStyleName("tiny");
    //        view_controls.addComponent (run);

}

From source file:org.lucidj.iconlist.renderer.IconListRenderer.java

License:Apache License

private AbstractComponent create_icon(Map<String, Object> component) {
    String icon_title = (String) component.get("iconTitle");

    if (icon_title == null) {
        icon_title = "No title";
    }//from   ww w.ja va  2s  .c om

    Resource icon_resource = iconHelper.getIcon((String) component.get("iconUrl"), 32);

    Button button_icon = new Button(icon_title);
    button_icon.setIcon(icon_resource);
    button_icon.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    button_icon.addStyleName(ValoTheme.BUTTON_SMALL);
    button_icon.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    button_icon.addStyleName("x-icon-button");
    button_icon.addStyleName("icon-size-32");
    button_icon.addClickListener(this);
    button_icon.setWidthUndefined();
    button_caption_wrap(button_icon);

    // Put the component in a D&D wrapper and allow dragging it
    final DragAndDropWrapper icon_dd_wrap = new DragAndDropWrapper(button_icon);
    icon_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT);

    // Set the wrapper to wrap tightly around the component
    icon_dd_wrap.setSizeUndefined();
    icon_dd_wrap.setData(component);

    // Set ID for drag-drop AND on the Label for double-click
    if (component.containsKey("entryId")) {
        String entryId = (String) component.get("entryId");
        icon_dd_wrap.setId(entryId);
        button_icon.setId(entryId);
    }

    // Component data is the map itself
    button_icon.setData(component);

    // Remember this association
    component_to_vaadin.put(component, icon_dd_wrap);
    return (icon_dd_wrap);
}