Example usage for com.vaadin.ui Button setIcon

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

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

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/* w ww .ja  va  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.trivago.mail.pigeon.web.components.templates.ActionButtonColumnGenerator.java

License:Apache License

@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
    HorizontalLayout hl = new HorizontalLayout();

    Button deleteButton = new Button();
    deleteButton.setImmediate(true);/*from w  w  w  .  ja  v  a  2 s. c o m*/
    deleteButton.setIcon(new ThemeResource("../runo/icons/16/trash.png"));
    deleteButton.setDescription("Delete template");
    deleteButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Transaction tx = ConnectionFactory.getDatabase().beginTx();
            try {
                MailTemplate mt = new MailTemplate((Long) itemId);
                ConnectionFactory.getNewsletterIndex().remove(mt.getDataNode());

                for (Relationship r : mt.getDataNode().getRelationships()) {
                    r.delete();
                }
                mt.getDataNode().delete();

                source.removeItem(itemId);
                source.getWindow().showNotification("Successfully deleted.");
                tx.success();
            } catch (Exception e) {
                source.getWindow().showNotification("Error while deleting entry: " + e.getMessage(),
                        Window.Notification.TYPE_ERROR_MESSAGE);
                log.error(e);
                tx.failure();
            } finally {
                tx.finish();
            }
        }
    });

    Button editButton = new Button();
    editButton.setImmediate(true);
    editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));
    editButton.setDescription("Edit template");
    editButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddTemplate(
                    (TemplateList) source.getParent().getParent().getParent(), (Long) itemId);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    hl.addComponent(editButton);
    hl.addComponent(deleteButton);
    return hl;
}

From source file:com.trivago.mail.pigeon.web.components.templates.TemplateList.java

License:Apache License

public TemplateList() {

    final TemplateList nl = this;
    final Panel rootPanel = new Panel("Newsletter");
    rootPanel.setWidth("800px");

    viewTable = new Table();
    viewTable.setWidth("100%");
    beanContainer = new BeanContainer<Long, MailTemplate>(MailTemplate.class);

    Button senderListNewButton = new Button("New Template");
    senderListNewButton.setImmediate(true);
    senderListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png"));
    senderListNewButton.addListener(new Button.ClickListener() {
        @Override//from w ww . j  a v  a2  s  . com
        public void buttonClick(Button.ClickEvent event) {
            Window modalNewWindow = new ModalAddTemplate(nl);
            event.getButton().getWindow().addWindow(modalNewWindow);
            modalNewWindow.setVisible(true);
        }
    });

    List<MailTemplate> mailList = getTemplateList();
    for (MailTemplate mail : mailList) {
        beanContainer.addItem(mail.getId(), mail);
    }

    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", "subject", "Actions" });

    viewTable.setColumnHeaders(new String[] { "ID", "Subject", "Actions" });

    viewTable.setColumnExpandRatio(6, 2);

    HorizontalLayout topButtonLayout = new HorizontalLayout();
    topButtonLayout.addComponent(senderListNewButton);
    // topButtonLayout.addComponent(statusPopup);
    topButtonLayout.setMargin(false, false, true, false);

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

    setCompositionRoot(rootPanel);
}

From source file:com.vphakala.Toolbar.java

public Toolbar(String windowName, Button read, Button create, Button update, Button delete) {
    setSpacing(true);//from  w  w  w.  j ava 2s. c o m

    create.setIcon(FontAwesome.USER_PLUS);
    create.setDescription("Create a new " + windowName + ".");

    read.setIcon(FontAwesome.USER);
    read.setDescription("Read the " + windowName + ". Insert NAME.");

    update.setIcon(FontAwesome.SAVE);
    update.setDescription("Store the " + windowName + " data.");

    delete.setIcon(FontAwesome.TRASH);
    delete.setDescription("Remove the " + windowName);

    addComponents(read, create, update, delete);
}

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/*from ww  w .  java2  s.c om*/
        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.wintindustries.pfserver.interfaces.view.dashboard.DashboardMenu.java

private Component buildToggleButton() {
    Button valoMenuToggleButton = new Button("Menu", new ClickListener() {
        @Override//  w ww. ja  va2s.c  om
        public void buttonClick(final ClickEvent event) {
            if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
                getCompositionRoot().removeStyleName(STYLE_VISIBLE);
            } else {
                getCompositionRoot().addStyleName(STYLE_VISIBLE);
            }
        }
    });
    valoMenuToggleButton.setIcon(FontAwesome.LIST);
    valoMenuToggleButton.addStyleName("valo-menu-toggle");
    valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_SMALL);
    return valoMenuToggleButton;
}

From source file:de.fatalix.bookery.view.admin.AppUserCard.java

License:Open Source License

private HorizontalLayout createHeader() {
    captionLabel = new Label("some.user");
    Button deleteUser = new Button(null, new Button.ClickListener() {

        @Override/* w  w w.ja va  2 s  .c om*/
        public void buttonClick(Button.ClickEvent event) {
            presenter.deleteUser(appUser);
            for (Listener listener : listeners) {
                listener.userDeleted(AppUserCard.this);
            }
        }
    });
    deleteUser.setIcon(FontAwesome.TIMES_CIRCLE);
    deleteUser.addStyleName("borderless");
    deleteUser.addStyleName("icon-only");

    HorizontalLayout captionLayout = new HorizontalLayout();
    captionLayout.addStyleName("v-panel-caption");
    captionLayout.setWidth("100%");
    captionLayout.addComponents(captionLabel, deleteUser);
    captionLayout.setExpandRatio(captionLabel, 1);

    return captionLayout;
}

From source file:de.fatalix.bookery.view.admin.BatchJobCard.java

private HorizontalLayout createHeader() {
    captionLabel = new Label("some.batchjob");

    Button deleteBatchJob = new Button(null, new Button.ClickListener() {

        @Override//from   w  w w . java  2 s. co m
        public void buttonClick(Button.ClickEvent event) {
            presenter.deleteBatchJob(jobConfig);
            for (BatchJobCard.Listener listener : listeners) {
                listener.jobDeleted(BatchJobCard.this);
            }
        }
    });
    deleteBatchJob.setIcon(FontAwesome.TIMES_CIRCLE);
    deleteBatchJob.addStyleName("borderless");
    deleteBatchJob.addStyleName("icon-only");

    HorizontalLayout captionLayout = new HorizontalLayout();
    captionLayout.addStyleName("v-panel-caption");
    captionLayout.setWidth("100%");
    captionLayout.addComponents(captionLabel, deleteBatchJob);
    captionLayout.setExpandRatio(captionLabel, 1);

    return captionLayout;
}

From source file:de.kaiserpfalzEdv.vaadin.menu.impl.MenuImpl.java

License:Apache License

@Inject
public MenuImpl(final Authenticator accessControl, final EventBus bus, final I18NHandler i18n,
        final List<View> allViews) {
    this.accessControl = accessControl;
    this.bus = bus;
    this.i18n = i18n;
    this.allViews = allViews;

    setPrimaryStyleName(ValoTheme.MENU_ROOT);
    menuPart = new CssLayout();
    menuPart.addStyleName(ValoTheme.MENU_PART);

    // header of the menu
    final HorizontalLayout top = new HorizontalLayout();
    top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    top.addStyleName(ValoTheme.MENU_TITLE);
    top.setSpacing(true);//from w w w  .  jav a2s.  c o  m
    Label title = new Label(translate("application.name"));
    title.addStyleName(ValoTheme.LABEL_H3);
    title.setSizeUndefined();
    Image image = new Image(null, new ThemeResource("img/table-logo.png"));
    image.setStyleName("logo");
    top.addComponent(image);
    top.addComponent(title);
    menuPart.addComponent(top);

    // logout menu item
    MenuBar logoutMenu = new MenuBar();
    logoutMenu.addItem(translate("button.logout.caption"), FontAwesome.valueOf(translate("button.logout.icon")),
            selectedItem -> {
                VaadinSession.getCurrent().getSession().invalidate();
                Page.getCurrent().reload();
            });

    logoutMenu.addStyleName("user-menu");
    menuPart.addComponent(logoutMenu);

    // button for toggling the visibility of the menu when on a small screen
    final Button showMenu = new Button(translate("application.name"), new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            if (menuPart.getStyleName().contains(VALO_MENU_VISIBLE)) {
                menuPart.removeStyleName(VALO_MENU_VISIBLE);
            } else {
                menuPart.addStyleName(VALO_MENU_VISIBLE);
            }
        }
    });
    showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY);
    showMenu.addStyleName(ValoTheme.BUTTON_SMALL);
    showMenu.addStyleName(VALO_MENU_TOGGLE);
    showMenu.setIcon(FontAwesome.NAVICON);
    menuPart.addComponent(showMenu);

    // container for the navigation buttons, which are added by addView()
    menuItemsLayout = new CssLayout();
    menuItemsLayout.setPrimaryStyleName(VALO_MENUITEMS);
    menuPart.addComponent(menuItemsLayout);

    addComponent(menuPart);
}

From source file:de.kaiserpfalzEdv.vaadin.menu.impl.MenuImpl.java

License:Apache License

private void createViewButton(final String name, String caption, Resource icon, int index) {
    Button button = new Button(translate(caption), event -> {
        LOG.trace("Menu click: {}", name);
        bus.post(new NavigateToEvent(this, name));
    });/*ww  w.j a  va2  s  .co  m*/
    button.setPrimaryStyleName(ValoTheme.MENU_ITEM);
    button.setIcon(icon);
    viewButtons.put(index, button);

    LOG.debug("Created menu entry: {}", caption);
}