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:me.uni.emuseo.view.common.paging.PagedTableLayout.java

License:Open Source License

private Button createPageButton(int i) {
    Button pageButton = new Button();
    pageButton.setCaption(((Integer) i).toString());
    pageButton.setData(i - 1);
    pageButton.addClickListener(pageButtonListener);
    return pageButton;
}

From source file:nl.amc.biolab.nsg.display.component.LoginUI.java

License:Open Source License

public LoginUI(final MainControl mainControl) {
    setWidth("100%");
    setHeight("300px");

    layout.setWidth("100%");
    layout.setHeight("300px");
    layout.addComponent(form);//from   w  w  w  .  j  a v  a2  s  .c o  m

    setCompositionRoot(layout);

    final TextField name = new TextField("Please enter your XNAT username");
    final PasswordField xnatPassword = new PasswordField("Please enter your XNAT password");

    xnatPassword.setRequired(true);

    form.addField("xnatUsername", name);
    form.addField("xnatPassword", xnatPassword);

    final Button okButton = new Button("ok");

    okButton.setClickShortcut(KeyCode.ENTER);
    okButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -6535226372165482804L;

        public void buttonClick(ClickEvent event) {
            User user = null;

            user = login((String) name.getValue(), (String) xnatPassword.getValue());
            xnatPassword.setValue("");

            if (user == null) {
                return;
            }

            okButton.setData(user);
            mainControl.init(user);

            app.getMainWindow().executeJavaScript("window.location.reload();");
        }
    });

    form.getFooter().addComponent(okButton);
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingForm.java

License:Open Source License

public void setButtons() {
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setHeight("40px");
    buttons.setSpacing(true);//  w w w . j a  va2 s.  c o m
    getLayout().addComponent(buttons);

    final Button startButton = new NativeButton();

    startButton.setCaption(SUBMIT);
    startButton.setImmediate(true);
    startButton.setWidth("-1px");
    startButton.setHeight("-1px");
    startButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1906358615316029946L;

        public void buttonClick(ClickEvent event) {
            System.out.println(app.getValue());

            Set<Long> inputDbIds = new HashSet<Long>();

            for (Object iid : inputData.getItemIds()) {
                inputData.select(iid);

                inputDbIds.add(((DataElement) iid).getDbId());
            }

            ((VaadinTestApplication) getApplication()).getUserDataService().setDataElementDbIds(inputDbIds);

            form.commit();

            processing.setApplication((Application) app.getValue());

            startButton.setData(processing);

            form.fireEvent(new Event(startButton));
        }
    });

    buttons.addComponent(startButton);
    buttons.setComponentAlignment(startButton, Alignment.TOP_RIGHT);

    final Button delButton = new NativeButton();
    delButton.setCaption("remove inputs");
    delButton.setImmediate(true);
    delButton.setWidth("-1px");
    delButton.setHeight("-1px");
    delButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -3377452914254101817L;

        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            if (inputData.getValue() != null) {
                for (DataElement de : (Set<DataElement>) inputData.getValue()) {
                    inputData.removeItem(de);
                    dataElements.remove(de);
                }
            }
        }
    });
    buttons.addComponent(delButton);
    buttons.setComponentAlignment(delButton, Alignment.TOP_RIGHT);
}

From source file:nl.kpmg.lcm.ui.view.administration.AuthorizedLcmPanel.java

License:Apache License

private HorizontalLayout createActionsLayout(AuthorizedLcmRepresentation item) {

    HorizontalLayout actionsLayout = new HorizontalLayout();

    Button viewButton = new Button("view");
    viewButton.setData(item);
    viewButton.addClickListener((event) -> {
        AuthorizedLcmRepresentation data = (AuthorizedLcmRepresentation) event.getButton().getData();
        setSelectedAuthorizedLcm(data);//from   w  w  w  . j  a va 2s  .  c  om
    });
    viewButton.addStyleName("link");

    Button editButton = new Button("edit");
    editButton.setData(item);
    editButton.addClickListener(new EditAuthorizedLcmListener(this, restClientService));
    editButton.addStyleName("link");

    Button deleteButton = new Button("delete");
    deleteButton.setData(item);
    deleteButton.addClickListener(new DeleteAuthorizedLcmListener(this, restClientService));
    deleteButton.addStyleName("link");

    actionsLayout.addComponent(viewButton);
    actionsLayout.addComponent(editButton);
    actionsLayout.addComponent(deleteButton);

    return actionsLayout;
}

From source file:nl.kpmg.lcm.ui.view.administration.RemoteLcmPanel.java

License:Apache License

private HorizontalLayout createActionsLayout(RemoteLcmRepresentation item) {

    HorizontalLayout actionsLayout = new HorizontalLayout();

    Button viewButton = new Button("view");
    viewButton.setData(item);
    viewButton.addClickListener((event) -> {
        RemoteLcmRepresentation data = (RemoteLcmRepresentation) event.getButton().getData();
        setSelectedRemoteLcm(data);/*from  w  ww  .j  av a2s  . c  o m*/
    });
    viewButton.addStyleName("link");

    Button editButton = new Button("edit");
    editButton.setData(item);
    editButton.addClickListener(new EditRemoteLcmListener(this, restClientService));
    editButton.addStyleName("link");

    Button deleteButton = new Button("delete");
    deleteButton.setData(item);
    deleteButton.addClickListener(new DeleteRemoteLcmListener(this, restClientService));
    deleteButton.addStyleName("link");

    Button exportUsersButton = new Button("export users");
    exportUsersButton.setData(item);
    exportUsersButton.addClickListener(new ExportUsersToRemoteLcmListener(this, restClientService));
    exportUsersButton.addStyleName("link");

    Button testButton = new Button("test");
    testButton.setData(item);
    testButton.addClickListener(new TestRemoteLcmListener(this, restClientService));
    testButton.addStyleName("link");

    actionsLayout.addComponent(viewButton);
    actionsLayout.addComponent(editButton);
    actionsLayout.addComponent(deleteButton);
    actionsLayout.addComponent(exportUsersButton);
    actionsLayout.addComponent(testButton);

    return actionsLayout;
}

From source file:nl.kpmg.lcm.ui.view.administration.StoragePanel.java

License:Apache License

private HorizontalLayout createActionsLayout(StorageRepresentation item) {

    HorizontalLayout actionsLayout = new HorizontalLayout();

    Button viewButton = new Button("view");
    viewButton.setData(item);
    viewButton.addClickListener((event) -> {
        StorageRepresentation data = (StorageRepresentation) event.getButton().getData();
        setSelectedStorage(data);//from   ww w  .  jav  a 2 s  .c om
    });
    viewButton.addStyleName("link");

    Button editButton = new Button("edit");
    editButton.setData(item);
    editButton.addClickListener(new EditStorageListener(this, restClientService));
    editButton.addStyleName("link");

    Button deleteButton = new Button("delete");
    deleteButton.setData(item);
    deleteButton.addClickListener(new DeleteStorageListener(this, restClientService));
    deleteButton.addStyleName("link");

    Button testButton = new Button("test connection");
    testButton.setData(item);
    testButton.addClickListener(new TestStorageListener(this, restClientService));
    testButton.addStyleName("link");

    actionsLayout.addComponent(viewButton);
    actionsLayout.addComponent(editButton);
    actionsLayout.addComponent(deleteButton);
    actionsLayout.addComponent(testButton);

    return actionsLayout;
}

From source file:nl.kpmg.lcm.ui.view.administration.UserGroupPanel.java

License:Apache License

private HorizontalLayout createActionsLayout(UserGroupRepresentation item) {

    HorizontalLayout actionsLayout = new HorizontalLayout();

    Button viewButton = new Button("view");
    viewButton.setData(item);
    viewButton.addClickListener((event) -> {
        UserGroupRepresentation data = (UserGroupRepresentation) event.getButton().getData();
        setSelectedUser(data);// ww  w  . j  a  va  2  s. c  o  m
    });
    viewButton.addStyleName("link");

    Button editButton = new Button("edit");
    editButton.setData(item);
    editButton.addClickListener(new EditUserGroupListener(this, restClientService));
    editButton.addStyleName("link");

    Button deleteButton = new Button("delete");
    deleteButton.setData(item);
    deleteButton.addClickListener(new DeleteUserGroupListener(this, restClientService));
    deleteButton.addStyleName("link");

    actionsLayout.addComponent(viewButton);
    actionsLayout.addComponent(editButton);
    actionsLayout.addComponent(deleteButton);

    return actionsLayout;
}

From source file:nl.kpmg.lcm.ui.view.administration.UserPanel.java

License:Apache License

private HorizontalLayout createActionsLayout(UserRepresentation item) {

    HorizontalLayout actionsLayout = new HorizontalLayout();

    Button viewButton = new Button("view");
    viewButton.setData(item);
    viewButton.addClickListener((event) -> {
        UserRepresentation data = (UserRepresentation) event.getButton().getData();
        setSelectedUser(data);/*  w  w w  . j  ava2s  . c o  m*/
    });
    viewButton.addStyleName("link");

    Button editButton = new Button("edit");
    editButton.setData(item);
    editButton.addClickListener(new EditUserListener(this, restClientService));
    editButton.addStyleName("link");

    Button deleteButton = new Button("delete");
    deleteButton.setData(item);
    deleteButton.addClickListener(new DeleteUserListener(this, restClientService));
    deleteButton.addStyleName("link");

    actionsLayout.addComponent(viewButton);
    actionsLayout.addComponent(editButton);
    actionsLayout.addComponent(deleteButton);

    return actionsLayout;
}

From source file:nl.kpmg.lcm.ui.view.MetadataOverviewViewImpl.java

License:Apache License

private void refreshMetadataOverview() {
    table.removeAllItems();//  ww  w  .ja v a 2s .  c om
    try {
        items = restClientService.getLocalMetadata();

        for (MetaDataRepresentation item : items.getItems()) {
            MetaDataWrapper metaDataWrapper;
            try {
                metaDataWrapper = new MetaDataWrapper(item.getItem());
            } catch (LcmValidationException lve) {
                LOGGER.warn("Unable to create wrapper around metadata. Message: " + lve.getMessage());
                continue;
            }

            HorizontalLayout actionsLayout = new HorizontalLayout();

            Button viewButton = new Button("view");
            viewButton.setData(item);
            viewButton.addClickListener(new ViewButtonClickListener());
            viewButton.addStyleName("link");

            Button enrichButton = new Button("enrich");
            enrichButton.setData(item);
            enrichButton.addClickListener(new EnrichButtonClickListener());
            enrichButton.addStyleName("link");

            actionsLayout.addComponent(viewButton);
            actionsLayout.addComponent(enrichButton);

            addPathToTable(metaDataWrapper.getData().getPath());

            table.addItem(new Object[] { metaDataWrapper.getName(), metaDataWrapper.getData().getUri(),
                    actionsLayout }, metaDataWrapper.getId());
            table.setChildrenAllowed(metaDataWrapper.getId(), false);
            table.setParent(metaDataWrapper.getId(), metaDataWrapper.getData().getPath());
        }
    } catch (AuthenticationException ex) {
        getUI().getNavigator().navigateTo("");
    } catch (ServerException se) {
        Notification.show("Cannot instantiate client HTTPS endpoint");
        getUI().getNavigator().navigateTo("");
    } catch (LcmBadRequestException ex) {
        Notification.show("Couldn't fetch remote data. Message:" + ex.getMessage());
    }
}

From source file:nl.kpmg.lcm.ui.view.transfer.MonitorPanel.java

License:Apache License

private HorizontalLayout createActionsLayout(TaskDescription item) {

    HorizontalLayout actionsLayout = new HorizontalLayout();

    Button viewButton = new Button("view progress");
    viewButton.setData(item);
    viewButton.addClickListener((event) -> {
        TaskDescription description = (TaskDescription) event.getButton().getData();
        indicationTable.removeAllItems();
        ListIterator li = description.getProgress().listIterator(description.getProgress().size());
        while (li.hasPrevious()) {
            ProgressIndication indication = (ProgressIndication) li.previous();
            indicationTable.addItem(/*from ww w .j a v a 2s  .c o  m*/
                    new Object[] { indication.getTimestamp().toString(), indication.getMessage() }, null);
        }
    });
    viewButton.addStyleName("link");

    actionsLayout.addComponent(viewButton);

    return actionsLayout;
}