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:uicomponents.WizardUploadsPanel.java

License:Open Source License

private void addListeners() {

    context.addValueChangeListener(new ValueChangeListener() {

        @Override//  w  w  w  .  ja  va 2  s  .c o m
        public void valueChange(ValueChangeEvent event) {
            add.setVisible(current != null);
        }
    });

    add.addClickListener(new ClickListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void buttonClick(ClickEvent event) {
            Button delete = new Button();
            Styles.iconButton(delete, FontAwesome.UNDO);

            Object itemId = toUpload.addItem();

            delete.setData(itemId);
            String secondary = fileInfo.getValue();
            String cntxt = (String) context.getValue();
            attachments.put(itemId, new AttachmentInformation(current.getName(), secondary, userID,
                    getBarcode(cntxt), cntxt, cntxt));

            delete.addClickListener(new Button.ClickListener() {
                /**
                * 
                */
                private static final long serialVersionUID = 5414603256990177472L;

                @Override
                public void buttonClick(ClickEvent event) {
                    Integer iid = (Integer) event.getButton().getData();
                    toUpload.removeItem(iid);
                    attachments.remove(iid);
                    tableChanged();
                }
            });
            toUpload.getContainerProperty(itemId, "Info").setValue(secondary);
            toUpload.getContainerProperty(itemId, "Context").setValue(cntxt);
            toUpload.getContainerProperty(itemId, "Remove").setValue(delete);
            tableChanged();
            add.setVisible(false);
            fileInfo.setVisible(false);
            context.setVisible(false);
        }

        private String getBarcode(String choice) {
            if (choice.equals("General Infos"))
                return project + "000";
            else
                return project + choice.split(" ")[0];
        }
    });
}

From source file:views.MultiAffiliationTab.java

License:Open Source License

public void addDataToTable(List<Person> personsWithAffiliations) {
    for (Person p : personsWithAffiliations) {
        // String title = p.getTitle();
        // String first = p.getFirst();
        // String last = p.getLast();
        Map<Integer, RoleAt> map = p.getAffiliationInfos();
        for (Integer i : p.getAffiliationInfos().keySet()) {
            personAffiliationsInTable.put(i, p);
            String affiliation = map.get(i).getAffiliation();
            String role = map.get(i).getRole();
            List<Object> row = new ArrayList<Object>();
            // row.add(title);
            // row.add(first);
            // row.add(last);
            row.add(affiliation);/*from  w ww. j av  a  2 s  .com*/
            ComboBox roleInput = new ComboBox("", availableRoles);
            roleInput.setStyleName(ValoTheme.COMBOBOX_SMALL);
            roleInput.setValue(role);
            row.add(roleInput);
            Button delete = new Button("Remove");
            row.add(delete);
            delete.setData(i);
            delete.addClickListener(new Button.ClickListener() {
                /**
                 * 
                 */
                private static final long serialVersionUID = 5414693256990177472L;

                @Override
                public void buttonClick(ClickEvent event) {
                    Button b = event.getButton();
                    Integer iid = (Integer) b.getData();
                    table.removeItem(iid);
                    table.setPageLength(table.size());
                    personAffiliationsInTable.remove(iid);
                }
            });
            table.addItem(row.toArray(), i);
        }
    }
    table.setPageLength(table.size());
}