Example usage for com.vaadin.ui Button setData

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

Introduction

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

Prototype

public void setData(Object data) 

Source Link

Document

Sets the data object, that can be used for any application specific data.

Usage

From source file:org.activiti.kickstart.ui.table.TaskTable.java

License:Apache License

protected HorizontalLayout generateActionButtons(Object taskItemId) {
    HorizontalLayout actionButtons = new HorizontalLayout();

    FormDto form = taskFormModel.getForm(taskItemId);
    Button formButton = new Button(form == null ? "Create form" : "Edit form");
    formButton.addListener(new ShowFormClickListener(viewManager, taskFormModel, taskItemId));
    formButton.setData(taskItemId);
    actionButtons.addComponent(formButton);

    Button deleteTaskButton = new Button("-");
    deleteTaskButton.setData(taskItemId);
    deleteTaskButton.addListener(new DeleteTaskClickListener(this));
    actionButtons.addComponent(deleteTaskButton);

    Button addTaskButton = new Button("+");
    addTaskButton.setData(taskItemId);//from   w  ww. j  ava 2 s  .co m
    addTaskButton.addListener(new AddTaskClickListener(this));
    actionButtons.addComponent(addTaskButton);

    return actionButtons;
}

From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java

License:Apache License

/**
 * Creates a remove-item button for the given repository object.
 * //from w w  w.j  av a  2 s .  c  o m
 * @param object
 *            the object to create a remove-item button, cannot be <code>null</code>;
 * @param displayName
 *            the display name for the description of the button, cannot be <code>null</code>.
 * @return a remove-item button, never <code>null</code>.
 */
protected final Button createRemoveItemButton(RepositoryObject object, String displayName) {
    Button result = new Button();
    result.setIcon(createIconResource("trash"));
    result.setData(object.getDefinition());
    result.setStyleName("small tiny");
    result.setDescription("Delete " + displayName);
    result.setDisableOnClick(true);

    result.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            try {
                handleItemRemoveObject(event.getButton().getData());
            } catch (Exception e) {
                // ACE-246: notify user when the removal failed!
                getWindow().showNotification("Failed to remove item!", "<br/>Reason: " + e.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });

    return result;
}

From source file:org.apache.ace.webui.vaadin.component.BaseObjectPanel.java

License:Apache License

/**
 * Creates a remove-link button for the given repository object.
 * /*from   w ww . jav  a  2 s.  c o  m*/
 * @param object
 *            the object to create a remove-link button, cannot be <code>null</code>;
 * @param displayName
 *            the display name for the description of the button, cannot be <code>null</code>.
 * @return a remove-link button, never <code>null</code>.
 */
protected final Button createRemoveLinkButton(RepositoryObject object, String displayName) {
    Button result = new Button();
    result.setIcon(createIconResource("unlink"));
    result.setStyleName("small tiny");
    result.setData(object.getDefinition());
    result.setDescription("Unlink " + displayName);
    // Only enable this button when actually selected...
    result.setEnabled(false);
    result.setDisableOnClick(true);

    result.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            handleItemRemoveLink(event.getButton().getData());
        }

    });

    return result;
}

From source file:org.apache.ace.webui.vaadin.component.ConfirmationDialog.java

License:Apache License

/**
 * Adds all components to this dialog./*from w  w  w.j  a  va 2 s . c o m*/
 * 
 * @param message
 *            the optional message to display, can be <code>null</code>;
 * @param buttonNames
 *            the names of the buttons to add, never <code>null</code> or empty.
 */
protected void addComponents(String message, String defaultButton, String... buttonNames) {
    if (message != null) {
        addComponent(new Label(message));
    }

    GridLayout gl = new GridLayout(buttonNames.length + 1, 1);
    gl.setSpacing(true);
    gl.setWidth("100%");

    gl.addComponent(new Label(" "));
    gl.setColumnExpandRatio(0, 1.0f);

    for (String buttonName : buttonNames) {
        Button button = new Button(buttonName, this);
        button.setData(buttonName);
        if (defaultButton != null && defaultButton.equals(buttonName)) {
            button.setStyleName(Reindeer.BUTTON_DEFAULT);
            button.setClickShortcut(KeyCode.ENTER);
            // Request focus in this window...
            button.focus();
        }
        gl.addComponent(button);
    }

    addComponent(gl);
}

From source file:org.eclipse.hawkbit.ui.artifacts.details.ArtifactDetailsLayout.java

License:Open Source License

private void addGeneratedColumnButton(final Table table) {
    table.addGeneratedColumn(ACTION, new ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override/*from ww w . j ava2 s  .  com*/
        public Button generateCell(final Table source, final Object itemId, final Object columnId) {
            final String fileName = (String) table.getContainerDataSource().getItem(itemId)
                    .getItemProperty(PROVIDED_FILE_NAME).getValue();
            final Button deleteIcon = SPUIComponentProvider.getButton(
                    fileName + "-" + UIComponentIdProvider.UPLOAD_FILE_DELETE_ICON, "",
                    i18n.getMessage(UIMessageIdProvider.CAPTION_DISCARD),
                    ValoTheme.BUTTON_TINY + " " + "blueicon", true, FontAwesome.TRASH_O,
                    SPUIButtonStyleNoBorder.class);
            deleteIcon.setData(itemId);
            deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName));
            return deleteIcon;
        }
    });

}

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

private void populateUploadDetailsTable() {
    for (final CustomFile customFile : uploadLayout.getFileSelected()) {
        final String swNameVersion = HawkbitCommonUtil.getFormattedNameVersion(
                customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion());
        final String itemId = swNameVersion + "/" + customFile.getFileName();
        final Item newItem = tableContainer.addItem(itemId);
        final SoftwareModule bSoftwareModule = artifactUploadState.getBaseSwModuleList().get(swNameVersion);
        newItem.getItemProperty(BASE_SOFTWARE_ID).setValue(bSoftwareModule.getId());

        addFileNameLayout(newItem, swNameVersion, customFile.getFileName(), itemId);

        newItem.getItemProperty(SW_MODULE_NAME).setValue(HawkbitCommonUtil.getFormatedLabel(swNameVersion));
        newItem.getItemProperty(SIZE).setValue(customFile.getFileSize());
        final Button deleteIcon = SPUIComponentProvider.getButton(
                UIComponentIdProvider.UPLOAD_DELETE_ICON + "-" + itemId, "", SPUILabelDefinitions.DISCARD,
                ValoTheme.BUTTON_TINY + " " + "blueicon", true, FontAwesome.TRASH_O,
                SPUIButtonStyleSmallNoBorder.class);
        deleteIcon.addClickListener(this);
        deleteIcon.setData(itemId);
        newItem.getItemProperty(ACTION).setValue(deleteIcon);

        final TextField sha1 = createTextField(swNameVersion + "/" + customFile.getFileName() + "/sha1");

        final TextField md5 = createTextField(swNameVersion + "/" + customFile.getFileName() + "/md5");

        createTextField(swNameVersion + "/" + customFile.getFileName() + "/customFileName");

        newItem.getItemProperty(SHA1_CHECKSUM).setValue(sha1);
        newItem.getItemProperty(MD5_CHECKSUM).setValue(md5);
        newItem.getItemProperty(CUSTOM_FILE).setValue(customFile);
    }//from   www  .  ja  v  a2  s .c o  m
}

From source file:org.eclipse.hawkbit.ui.common.confirmwindow.layout.AbstractConfirmationWindowLayout.java

License:Open Source License

protected Button createDiscardButton(final Object itemId, final ClickListener clickListener) {
    final Button deletesDsIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
            ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY,
            SPUIButtonStyleSmallNoBorder.class);
    deletesDsIcon.setData(itemId);
    deletesDsIcon.setImmediate(true);//from   w w  w  . java 2  s .c o m
    deletesDsIcon.addClickListener(clickListener);
    return deletesDsIcon;
}

From source file:org.eclipse.hawkbit.ui.common.detailslayout.AbstractMetadataDetailsLayout.java

License:Open Source License

private Button customMetadataDetailButton(final String metadataKey) {
    final Button viewIcon = SPUIComponentProvider.getButton(getDetailLinkId(metadataKey), metadataKey,
            "View " + metadataKey + "  Metadata details", null, false, null, SPUIButtonStyleNoBorder.class);
    viewIcon.setData(metadataKey);
    viewIcon.addStyleName(ValoTheme.BUTTON_TINY + " " + ValoTheme.BUTTON_LINK + " " + "on-focus-no-border link"
            + " " + "text-style");
    viewIcon.addClickListener(event -> showMetadataDetails(metadataKey));
    return viewIcon;
}

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.
     *//*  www .  j a  v  a  2  s .c o m*/
    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.distributions.footer.DistributionsConfirmationWindowLayout.java

License:Open Source License

private ConfirmationTab createSMtypeDeleteConfirmationTab() {
    final ConfirmationTab tab = new ConfirmationTab();

    tab.getConfirmAll().setId(UIComponentIdProvider.SAVE_DELETE_SW_MODULE_TYPE);
    tab.getConfirmAll().setIcon(FontAwesome.TRASH_O);
    tab.getConfirmAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DELETE_ALL));
    tab.getConfirmAll().addClickListener(event -> deleteSMtypeAll(tab));

    tab.getDiscardAll().setCaption(i18n.getMessage(SPUILabelDefinitions.BUTTON_DISCARD_ALL));
    tab.getDiscardAll().setId(UIComponentIdProvider.DISCARD_SW_MODULE_TYPE);
    tab.getDiscardAll().addClickListener(event -> discardSMtypeAll(tab));

    // Add items container to the table.
    tab.getTable().setContainerDataSource(getSWModuleTypeTableContainer());

    // Add the discard action column
    tab.getTable().addGeneratedColumn(DISCARD, (source, itemId, columnId) -> {
        final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY);
        style.append(' ');
        style.append(SPUIStyleDefinitions.REDICON);
        final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD,
                style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class);
        deleteIcon.setData(itemId);
        deleteIcon.setImmediate(true);/* w ww. ja va2 s  .  c om*/
        deleteIcon.addClickListener(event -> discardSoftwareTypeDelete(
                (String) ((Button) event.getComponent()).getData(), itemId, tab));
        return deleteIcon;
    });

    tab.getTable().setVisibleColumns(SW_MODULE_TYPE_NAME, DISCARD);
    tab.getTable().setColumnHeaders(i18n.getMessage("header.first.delete.swmodule.type.table"),
            i18n.getMessage("header.second.delete.swmodule.type.table"));

    tab.getTable().setColumnExpandRatio(SW_MODULE_TYPE_NAME, 2);
    tab.getTable().setColumnExpandRatio(SW_DISCARD_CHGS, SPUIDefinitions.DISCARD_COLUMN_WIDTH);
    tab.getTable().setColumnAlignment(SW_DISCARD_CHGS, Align.CENTER);
    return tab;
}