Example usage for com.vaadin.ui Button Button

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

Introduction

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

Prototype

public Button(Resource icon, ClickListener listener) 

Source Link

Document

Creates a new push button with a click listener.

Usage

From source file:com.esofthead.mycollab.module.crm.view.activity.ActivityRelatedItemListComp.java

License:Open Source License

private void initUI() {
    if (allowCreateNew) {
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setSpacing(true);//  www  .  j  av  a2s  . co  m
        final Button newTaskBtn = new Button("New Task", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final Button.ClickEvent event) {
                fireNewRelatedItem("task");
            }
        });
        newTaskBtn.setIcon(FontAwesome.PLUS);
        newTaskBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_TASK));
        newTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        buttonLayout.addComponent(newTaskBtn);

        final Button newCallBtn = new Button("New Call", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final Button.ClickEvent event) {
                fireNewRelatedItem("call");
            }
        });
        newCallBtn.setIcon(FontAwesome.PLUS);
        newCallBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL));
        newCallBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        buttonLayout.addComponent(newCallBtn);

        final Button newMeetingBtn = new Button("New Meeting", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final Button.ClickEvent event) {
                fireNewRelatedItem("call");
            }
        });
        newMeetingBtn.setIcon(FontAwesome.PLUS);
        newMeetingBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_MEETING));
        newMeetingBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        buttonLayout.addComponent(newMeetingBtn);

        this.addComponent(buttonLayout);
        this.addStyleName("activity-realated-content");
    }

    tableItem = new ActivityTableDisplay(Arrays.asList(
            new TableViewField(ActivityI18nEnum.FORM_SUBJECT, "subject", UIConstants.TABLE_EX_LABEL_WIDTH),
            new TableViewField(ActivityI18nEnum.FORM_STATUS, "status", UIConstants.TABLE_S_LABEL_WIDTH),
            new TableViewField(TaskI18nEnum.FORM_START_DATE, "startDate", UIConstants.TABLE_DATE_TIME_WIDTH),
            new TableViewField(TaskI18nEnum.TABLE_END_DATE_HEADER, "endDate",
                    UIConstants.TABLE_DATE_TIME_WIDTH)));

    tableItem.addTableListener(new TableClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(final TableClickEvent event) {
            final SimpleActivity simpleEvent = (SimpleActivity) event.getData();
            if (CrmTypeConstants.TASK.equals(simpleEvent.getEventType())) {
                EventBusFactory.getInstance().post(new ActivityEvent.TaskRead(this, simpleEvent.getId()));
            } else if (CrmTypeConstants.MEETING.equals(simpleEvent.getEventType())) {
                EventBusFactory.getInstance().post(new ActivityEvent.MeetingRead(this, simpleEvent.getId()));
            } else if (CrmTypeConstants.CALL.equals(simpleEvent.getEventType())) {
                EventBusFactory.getInstance().post(new ActivityEvent.CallRead(this, simpleEvent.getId()));
            }
        }
    });

    this.addComponent(tableItem);
}

From source file:com.esofthead.mycollab.module.crm.view.activity.ActivitySearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%").withSpacing(true)
            .withMargin(new MarginInfo(true, false, true, false));
    layout.setSizeUndefined();/*ww  w.j a v  a  2s . c  om*/
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.ACTIVITY, "Events");
    searchtitle.setStyleName(Reindeer.LABEL_H2);

    layout.with(searchtitle).withAlign(searchtitle, Alignment.MIDDLE_LEFT).expand(searchtitle);

    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL)
            || AppContext.canWrite(RolePermissionCollections.CRM_MEETING));
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.setCaption("New Task");
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void splitButtonClick(final SplitButton.SplitButtonClickEvent event) {
            EventBusFactory.getInstance().post(new ActivityEvent.TaskAdd(this, null));
        }
    });

    final VerticalLayout btnControlsLayout = new VerticalLayout();
    controlsBtn.setContent(btnControlsLayout);

    final Button createMeetingBtn = new Button("New Meeting", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            controlsBtn.setPopupVisible(false);
            EventBusFactory.getInstance().post(new ActivityEvent.MeetingAdd(this, null));
        }
    });
    createMeetingBtn.setStyleName("link");
    btnControlsLayout.addComponent(createMeetingBtn);
    createMeetingBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_MEETING));
    final Button createCallBtn = new Button("New Call", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            controlsBtn.setPopupVisible(false);
            EventBusFactory.getInstance().post(new ActivityEvent.CallAdd(this, null));
        }
    });
    createCallBtn.setStyleName("link");
    createCallBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL));
    btnControlsLayout.addComponent(createCallBtn);
    layout.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);

    ButtonGroup viewSwitcher = new ButtonGroup();

    Button calendarViewBtn = new Button("Calendar", new Button.ClickListener() {
        private static final long serialVersionUID = -793215433929884575L;

        @Override
        public void buttonClick(ClickEvent evt) {
            EventBusFactory.getInstance().post(new ActivityEvent.GotoCalendar(this, null));
        }
    });
    calendarViewBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    viewSwitcher.addButton(calendarViewBtn);

    Button activityListBtn = new Button("Activitities");
    activityListBtn.setStyleName("selected");
    activityListBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    viewSwitcher.addButton(activityListBtn);

    layout.with(viewSwitcher).withAlign(viewSwitcher, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.activity.CallListDashlet.java

License:Open Source License

public CallListDashlet() {
    super("My Calls", new VerticalLayout());

    tableItem = new CallTableDisplay(new TableViewField(null, "isClosed", UIConstants.TABLE_CONTROL_WIDTH),
            Arrays.asList(/*from ww w . j a  va 2 s.c o m*/
                    new TableViewField(CallI18nEnum.FORM_SUBJECT, "subject", UIConstants.TABLE_X_LABEL_WIDTH),
                    new TableViewField(TaskI18nEnum.FORM_START_DATE, "startdate",
                            UIConstants.TABLE_DATE_TIME_WIDTH),
                    new TableViewField(ActivityI18nEnum.FORM_STATUS, "status",
                            UIConstants.TABLE_S_LABEL_WIDTH)));

    tableItem.addTableListener(new TableClickListener() {

        @Override
        public void itemClick(final TableClickEvent event) {
            final SimpleCall call = (SimpleCall) event.getData();
            if ("isClosed".equals(event.getFieldName())) {
                call.setIsclosed(true);
                final CallService callService = ApplicationContextUtil.getSpringBean(CallService.class);
                callService.updateWithSession(call, AppContext.getUsername());
                display();
            }
        }
    });
    bodyContent.addComponent(tableItem);

    Button customizeViewBtn = new Button("", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {

        }
    });
    customizeViewBtn.setIcon(FontAwesome.ADJUST);
    customizeViewBtn.setDescription("Layout Options");
    customizeViewBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);

    this.addHeaderElement(customizeViewBtn);
}

From source file:com.esofthead.mycollab.module.crm.view.activity.CallTableDisplay.java

License:Open Source License

public CallTableDisplay(TableViewField requireColumn, List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(CallService.class), SimpleCall.class, requireColumn,
            displayColumns);//w  w  w.j  av  a2s . co m

    this.addGeneratedColumn("subject", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleCall call = CallTableDisplay.this.getBeanByIndex(itemId);

            LabelLink b = new LabelLink(call.getSubject(),
                    CrmLinkBuilder.generateCallPreviewLinkFul(call.getId()));

            if ("Held".equals(call.getStatus())) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            }
            return b;

        }
    });

    this.addGeneratedColumn("isClosed", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleCall call = CallTableDisplay.this.getBeanByIndex(itemId);
            Button b = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    fireTableEvent(new TableClickEvent(CallTableDisplay.this, call, "isClosed"));
                }
            });
            b.setIcon(FontAwesome.TRASH_O);
            b.setStyleName("link");
            b.setDescription("Close this call");
            return b;

        }
    });

    this.addGeneratedColumn("startdate", new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleCall call = CallTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDateTime(call.getStartdate()));

        }
    });
}

From source file:com.esofthead.mycollab.module.crm.view.activity.MeetingListDashlet.java

License:Open Source License

public MeetingListDashlet() {
    super("My Meetings", new VerticalLayout());

    tableItem = new MeetingTableDisplay(Arrays.asList(
            new TableViewField(MeetingI18nEnum.FORM_SUBJECT, "subject", UIConstants.TABLE_X_LABEL_WIDTH),
            new TableViewField(TaskI18nEnum.FORM_START_DATE, "startdate", UIConstants.TABLE_DATE_TIME_WIDTH),
            new TableViewField(ActivityI18nEnum.FORM_STATUS, "status", UIConstants.TABLE_S_LABEL_WIDTH)));

    bodyContent.addComponent(tableItem);

    Button customizeViewBtn = new Button("", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*from  w w  w .j a  va  2  s .  co m*/
        public void buttonClick(ClickEvent event) {

        }
    });
    customizeViewBtn.setIcon(FontAwesome.ADJUST);
    customizeViewBtn.setDescription("Layout Options");
    customizeViewBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);

    this.addHeaderElement(customizeViewBtn);
}

From source file:com.esofthead.mycollab.module.crm.view.campaign.CampaignAccountListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();/* w  ww .  ja va  2  s  . c  om*/
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_ACCOUNT));
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption(AppContext.getMessage(AccountI18nEnum.BUTTON_NEW_ACCOUNT));
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void splitButtonClick(final SplitButton.SplitButtonClickEvent event) {
            fireNewRelatedItem("");
        }
    });
    final Button selectBtn = new Button("Select from existing accounts", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final CampaignAccountSelectionWindow accountsWindow = new CampaignAccountSelectionWindow(
                    CampaignAccountListComp.this);
            final AccountSearchCriteria criteria = new AccountSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            UI.getCurrent().addWindow(accountsWindow);
            accountsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }
    });
    selectBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_select));
    selectBtn.setStyleName("link");
    VerticalLayout buttonControlLayout = new VerticalLayout();
    buttonControlLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlLayout);

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}

From source file:com.esofthead.mycollab.module.crm.view.campaign.CampaignAccountSelectionWindow.java

License:Open Source License

@Override
protected void initUI() {
    tableItem = new AccountTableDisplay(AccountTableFieldDef.selected,
            Arrays.asList(AccountTableFieldDef.accountname, AccountTableFieldDef.phoneoffice,
                    AccountTableFieldDef.email, AccountTableFieldDef.city));

    Button selectBtn = new Button("Select", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from w  w  w .j av  a  2 s .  c  o m
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    selectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    AccountSimpleSearchPanel accountSimpleSearchPanel = new AccountSimpleSearchPanel();
    accountSimpleSearchPanel.addSearchHandler(new SearchHandler<AccountSearchCriteria>() {

        @Override
        public void onSearch(AccountSearchCriteria criteria) {
            tableItem.setSearchCriteria(criteria);
        }

    });

    this.bodyContent.addComponent(accountSimpleSearchPanel);
    this.bodyContent.addComponent(selectBtn);
    this.bodyContent.addComponent(tableItem);
}

From source file:com.esofthead.mycollab.module.crm.view.campaign.CampaignContactListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();// w w  w. j a v a 2  s .  co  m
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT));
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = -5166203461087915517L;

        @Override
        public void splitButtonClick(final SplitButton.SplitButtonClickEvent event) {
            fireNewRelatedItem("");
        }
    });
    final Button selectBtn = new Button("Select from existing contacts", new Button.ClickListener() {
        private static final long serialVersionUID = -4257729842567787799L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final CampaignContactSelectionWindow contactsWindow = new CampaignContactSelectionWindow(
                    CampaignContactListComp.this);
            final ContactSearchCriteria criteria = new ContactSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            UI.getCurrent().addWindow(contactsWindow);
            contactsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }
    });
    selectBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_select));
    selectBtn.setStyleName("link");
    VerticalLayout buttonControlLayout = new VerticalLayout();
    buttonControlLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlLayout);

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}

From source file:com.esofthead.mycollab.module.crm.view.campaign.CampaignContactSelectionWindow.java

License:Open Source License

@Override
protected void initUI() {
    tableItem = new ContactTableDisplay(ContactTableFieldDef.selected, Arrays.asList(ContactTableFieldDef.name,
            ContactTableFieldDef.email, ContactTableFieldDef.phoneOffice, ContactTableFieldDef.account));

    Button selectBtn = new Button("Select", new Button.ClickListener() {

        @Override//from   w  w  w .  jav a  2s.c o  m
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    selectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    ContactSimpleSearchPanel contactSimpleSearchPanel = new ContactSimpleSearchPanel();
    contactSimpleSearchPanel.addSearchHandler(new SearchHandler<ContactSearchCriteria>() {

        @Override
        public void onSearch(ContactSearchCriteria criteria) {
            tableItem.setSearchCriteria(criteria);
        }

    });

    this.bodyContent.addComponent(contactSimpleSearchPanel);
    this.bodyContent.addComponent(selectBtn);
    this.bodyContent.addComponent(tableItem);
}

From source file:com.esofthead.mycollab.module.crm.view.campaign.CampaignLeadListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();//  w ww. j  a v  a2s.c o m
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_LEAD));
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption(AppContext.getMessage(LeadI18nEnum.BUTTON_NEW_LEAD));
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void splitButtonClick(final SplitButton.SplitButtonClickEvent event) {
            fireNewRelatedItem("");
        }
    });
    final Button selectBtn = new Button("Select from existing leads", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final CampaignLeadSelectionWindow leadsWindow = new CampaignLeadSelectionWindow(
                    CampaignLeadListComp.this);
            final LeadSearchCriteria criteria = new LeadSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            UI.getCurrent().addWindow(leadsWindow);
            leadsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }
    });
    selectBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_select));
    selectBtn.setStyleName("link");
    VerticalLayout buttonControlLayout = new VerticalLayout();
    buttonControlLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlLayout);

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}