Example usage for com.vaadin.ui Button setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:com.trivago.mail.pigeon.web.components.recipients.RecipientList.java

License:Apache License

private void init() {
    final Panel rootPanel = new Panel("Recipients");
    rootPanel.setWidth("800px");

    //      Button senderListNewButton = new Button("Add Sender");
    //      senderListNewButton.setImmediate(true);
    //      senderListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    //      senderListNewButton.addListener(new Button.ClickListener()
    //      {/*from   www  .j  a v  a2  s.c  o m*/
    //         @Override
    //         public void buttonClick(Button.ClickEvent event)
    //         {
    //            Window modalNewWindow = new ModalAddNewSender(sl);
    //            event.getButton().getWindow().addWindow(modalNewWindow);
    //            modalNewWindow.setVisible(true);
    //         }
    //      });

    viewTable = new Table();
    viewTable.setWidth("100%");
    final Button editButton = new Button("Edit");
    editButton.setImmediate(true);
    editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    editButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (viewTable.isEditable()) {
                viewTable.setEditable(false);
                editButton.setCaption("Edit");
                viewTable.requestRepaintAll();
                editButton.getWindow().showNotification("Save successful",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            } else {
                viewTable.setEditable(true);
                editButton.setCaption("Save");
                viewTable.requestRepaintAll();
            }
        }
    });

    Button exportTable = new Button("Export");
    exportTable.setImmediate(true);
    exportTable.setIcon(new ThemeResource("../runo/icons/16/document-xsl.png"));
    exportTable.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            log.debug("Starting export");
            TableExport te = new ExcelExport(viewTable, "Recipient list", "Recipient list",
                    "Recipient_list.xls", false);
            log.debug("Converting table");
            te.convertTable();
            log.debug("Sending converted table...");
            boolean success = te.sendConverted();
            if (success) {
                log.debug("Sending should be successful");
            } else {
                log.warn("Sending not successfull, maybe IOException occured?");
            }
        }
    });

    viewTable.setImmediate(true);
    beanContainer = new BeanContainer<>(Recipient.class);

    List<Recipient> recipientList = getRecipientList();
    for (Recipient recipient : recipientList) {
        beanContainer.addItem(recipient.getId(), recipient);
    }

    viewTable.setContainerDataSource(beanContainer);
    viewTable.addGeneratedColumn("Actions", new ActionButtonColumnGenerator());

    // First set the vis. cols, then the headlines (the other way round leads to an exception)
    viewTable.setVisibleColumns(new String[] { "id", "title", "firstname", "lastname", "email", "active",
            "gender", "birthday", "city", "country", "language", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Title", "Firstname", "Lastname", "E-Mail", "Active",
            "Gender", "Birthday", "City", "Country", "Language", "Actions" });

    viewTable.setColumnCollapsingAllowed(true);

    viewTable.setColumnCollapsed("gender", true);
    viewTable.setColumnCollapsed("title", true);
    viewTable.setColumnCollapsed("birthday", true);
    viewTable.setColumnCollapsed("city", true);
    viewTable.setColumnCollapsed("country", true);
    viewTable.setColumnCollapsed("language", true);

    viewTable.setColumnExpandRatio(3, 2);
    viewTable.setColumnExpandRatio(4, 2);

    HorizontalLayout topButtonLayout = new HorizontalLayout();
    topButtonLayout.setSpacing(true);
    topButtonLayout.setMargin(false, false, true, false);
    topButtonLayout.addComponent(editButton);
    topButtonLayout.addComponent(exportTable);

    rootPanel.addComponent(topButtonLayout);
    rootPanel.addComponent(viewTable);

    setCompositionRoot(rootPanel);
}

From source file:com.trivago.mail.pigeon.web.components.sender.SenderList.java

License:Apache License

public SenderList() {
    final SenderList sl = this;
    final Panel rootPanel = new Panel("Sender");
    rootPanel.setWidth("800px");

    Button senderListNewButton = new Button("Add Sender");
    senderListNewButton.setImmediate(true);
    senderListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    senderListNewButton.addListener(new Button.ClickListener() {
        @Override//from  www .  j  a  v a 2 s.c o  m
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddNewSender(sl);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    viewTable = new Table();
    viewTable.setWidth("100%");
    final Button editButton = new Button("Edit");
    editButton.setImmediate(true);
    editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    editButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (viewTable.isEditable()) {
                viewTable.setEditable(false);
                editButton.setCaption("Edit");
                viewTable.requestRepaintAll();
                editButton.getWindow().showNotification("Save successful",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
            } else {
                viewTable.setEditable(true);
                editButton.setCaption("Save");
                viewTable.requestRepaintAll();
            }
        }
    });

    viewTable.setImmediate(true);
    beanContainer = new BeanContainer<Long, Sender>(Sender.class);

    List<Sender> senderList = getSenderList();
    for (Sender sender : senderList) {
        beanContainer.addItem(sender.getId(), sender);
    }

    viewTable.setContainerDataSource(beanContainer);
    viewTable.addGeneratedColumn("Actions", new ActionButtonColumnGenerator());

    // First set the vis. cols, then the headlines (the other way round leads to an exception)
    viewTable.setVisibleColumns(
            new String[] { "id", "name", "fromMail", "replytoMail", "sentMailsCount", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Name", "E-Mail", "Reply To", "E-Mails sent", "Actions" });

    viewTable.setColumnExpandRatio(3, 2);
    viewTable.setColumnExpandRatio(4, 2);

    HorizontalLayout topButtonLayout = new HorizontalLayout();
    topButtonLayout.setSpacing(true);
    topButtonLayout.setMargin(false, false, true, false);
    topButtonLayout.addComponent(senderListNewButton);
    topButtonLayout.addComponent(editButton);

    rootPanel.addComponent(topButtonLayout);
    rootPanel.addComponent(viewTable);

    setCompositionRoot(rootPanel);

}

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.ui.UploadStateLayout.java

License:Apache License

private Button createCancelBtn() {
    Button button = new Button();
    button.addClickListener(new Button.ClickListener() {
        @Override/*  w w  w.  j  av a  2 s. c  o  m*/
        public void buttonClick(final Button.ClickEvent event) {
            uploadStatePanel.interruptUpload(fileDetailBean);
        }
    });
    button.setIcon(uploadStatePanel.getWindow().getCancelIconResource());
    button.setStyleName("small");
    button.setCaption(uploadStatePanel.getWindow().getCancelButtonCaption());
    return button;
}

From source file:com.wft.ui.WelcomeLoginApplication.java

License:Apache License

@Override
public void init() {
    window = new Window("Web Foot Tournament");

    subwindow = new Window("Connexion");
    // ...and make it modal
    subwindow.setModal(true);/*from   www . ja  v a  2s  . c  om*/
    subwindow.setClosable(false);
    subwindow.setResizable(false);
    subwindow.setWidth("50%");
    subwindow.setHeight("50%");

    // Configure the windows layout; by default a VerticalLayout
    verticalLayout = new VerticalLayout();
    subwindow.setContent(verticalLayout);
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setSizeFull();

    wftLoginForm.setSizeFull();
    verticalLayout.addComponent(wftLoginForm);
    verticalLayout.setComponentAlignment(wftLoginForm,
            new Alignment(Bits.ALIGNMENT_HORIZONTAL_CENTER | Bits.ALIGNMENT_VERTICAL_CENTER));

    Button createUserBtn = new Button();
    createUserBtn.setCaption("Not yet an user ? Create an account !");
    createUserBtn.addListener(new ClickListener() {

        public void buttonClick(ClickEvent event) {
            switchToCreateUserForm();
        }
    });
    verticalLayout.addComponent(createUserBtn);

    window.addWindow(subwindow);

    setMainWindow(window);

}

From source file:com.whymenu.MainUI.java

private void updateLocations() {
    locations.forEach((key, value) -> {
        Location location = value;
        if (!buttons.containsKey(key)) {
            Button button = new Button(location != null ? location.getDescription() : key);
            button.addClickListener((Button.ClickEvent event) -> {
                System.out.println("test");
            });// ww  w.  j a v  a2s.c  o  m
            mainLayout.addComponent(button);
            buttons.put(key, button);
        } else {
            Button button = buttons.get(key);
            if (!button.getCaption().equals(location.getDescription())) {
                button.setCaption(location.getDescription());
            }
        }
    });
    buttons.forEach((key, value) -> {
        if (!locations.containsKey(key)) {
            mainLayout.removeComponent(value);
            value = null;
        }
    });
}

From source file:de.escidoc.admintool.view.resource.PropertiesBinder.java

License:Open Source License

private void with(final Property itemProperty) {
    if (toBeBind instanceof Label) {
        ((Label) toBeBind).setPropertyDataSource(itemProperty);
    } else if (toBeBind instanceof Button) {
        final Button button = (Button) toBeBind;
        button.setCaption((String) itemProperty.getValue());
    } else {//from   w ww  . j  a v a 2  s.  com
        ((com.vaadin.ui.Field) toBeBind).setPropertyDataSource(itemProperty);
    }
}

From source file:de.fzi.fhemapi.view.vaadin.ui.devicepanels.OnOffDetails.java

License:Apache License

@Override
public List<DeviceDetailEntry> getDeviceDetails() {
    List<DeviceDetailEntry> entries = new LinkedList<DeviceDetailEntry>();

    final Button switchButton = new Button();
    switchButton.setImmediate(true);//w  w w .  ja v a2  s .c om
    String buttonLabel = "?";
    if (((OnOffActuator) device).state != null)
        buttonLabel = ((OnOffActuator) device).state ? "An" : "Aus";
    switchButton.setCaption(buttonLabel);
    switchButton.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            if (((OnOffActuator) device).state) {
                ((OnOffActuator) device).turnOff();
            } else {
                ((OnOffActuator) device).turnOn();
            }

            String buttonLabel = "?";
            if (((OnOffActuator) device).state != null)
                buttonLabel = ((OnOffActuator) device).state ? "An" : "Aus";
            switchButton.setCaption(buttonLabel);
            parent.reloadPage();
        }
    });

    entries.add(new DeviceDetailEntry("Schalten", switchButton));

    return entries;
}

From source file:de.metas.ui.web.vaadin.window.components.ATabToolbar.java

License:Open Source License

private void addToolbarButton(final ActionInfo actionInfo) {
    final String action = actionInfo.getAction();

    final Button button = new Button();
    button.setCaption(action);
    button.setData(actionInfo);/*  www  . j  av  a  2s .  c  o m*/
    button.setEnabled(model.isActionEnabled(action));
    button.addClickListener(actionButtonListener);

    action2button.put(action, button);

    addComponent(button);
}

From source file:de.metas.ui.web.vaadin.window.view.WindowPanelsBar.java

License:Open Source License

public void addNavigationShortcut(final Editor editor) {
    if (editor == null) {
        return;/*from  www .j  a  v  a  2 s .  com*/
    }

    final Component editorComp = editor.getComponent();
    if (editorComp == null) {
        return;
    }

    final Button button = new Button();
    button.setPrimaryStyleName("mf-tabbar-button");
    button.setCaption(editor.getCaption());
    content.addComponent(button);

    button.addClickListener(event -> UI.getCurrent().scrollIntoView(editorComp));
}

From source file:de.metas.ui.web.vaadin.window.view.WindowViewImpl.java

License:Open Source License

@Override
public void setActions(final ActionsList actions) {
    if (Objects.equals(this._actions, actions)) {
        return;/*www.  j av  a  2s.c  o  m*/
    }

    this._actions = ActionsList.copyOf(actions);

    //
    // Toolbar actions
    actionsPanel.removeAllComponents();
    for (final Action action : _actions) {
        if (!action.isToolbarAction()) {
            continue;
        }

        final String actionId = action.getActionId();

        final Button btn = new Button();
        btn.setCaption(action.getCaption());
        btn.setIcon(Theme.getVaadinResource(action.getIcon()));
        btn.addClickListener(event -> getWindowViewListener().onActionClicked(actionId));
        actionsPanel.addComponent(btn);

    }
}