Example usage for com.vaadin.ui Button setStyleName

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

Introduction

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

Prototype

@Override
    public void setStyleName(String style) 

Source Link

Usage

From source file:com.esofthead.mycollab.module.crm.ui.components.CrmPreviewFormControlsGenerator.java

License:Open Source License

public HorizontalLayout createButtonControls(int buttonEnableFlags, final String permissionItem) {

    layout.setStyleName("control-buttons");
    layout.setSpacing(true);//from w w w  . j a v  a2  s. co m
    layout.setSizeUndefined();

    boolean canRead = true;
    boolean canWrite = true;
    boolean canAccess = true;
    if (permissionItem != null) {
        canRead = AppContext.canRead(permissionItem);
        canWrite = AppContext.canWrite(permissionItem);
        canAccess = AppContext.canAccess(permissionItem);
    }

    MVerticalLayout popupButtonsControl = new MVerticalLayout()
            .withMargin(new MarginInfo(false, true, false, true));

    if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) {
        Button addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        final T item = previewForm.getBean();
                        previewForm.fireAddForm(item);
                    }
                });
        addBtn.setIcon(FontAwesome.PLUS);
        addBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        addBtn.setEnabled(canWrite);
        layout.addComponent(addBtn);
    }

    if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {
        Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        final T item = previewForm.getBean();
                        previewForm.fireEditForm(item);
                    }
                });
        editBtn.setIcon(FontAwesome.EDIT);
        editBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        editBtn.setEnabled(canWrite);
        layout.addComponent(editBtn);
    }

    if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) {
        Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        final T item = previewForm.getBean();
                        previewForm.fireDeleteForm(item);
                    }
                });
        deleteBtn.setIcon(FontAwesome.TRASH_O);
        deleteBtn.setStyleName(UIConstants.THEME_RED_LINK);
        layout.addComponent(deleteBtn);
        deleteBtn.setEnabled(canAccess);
    }

    if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) {
        Button cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        final T item = previewForm.getBean();
                        previewForm.fireCloneForm(item);
                    }
                });
        cloneBtn.setIcon(FontAwesome.ROAD);
        cloneBtn.setStyleName("link");
        popupButtonsControl.addComponent(cloneBtn);
    }

    if ((buttonEnableFlags & HISTORY_BTN_PRESENTED) == HISTORY_BTN_PRESENTED) {
        Button historyBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_HISTORY),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        optionBtn.setPopupVisible(false);
                        previewForm.showHistory();
                    }
                });
        historyBtn.setIcon(FontAwesome.HISTORY);
        historyBtn.setStyleName("link");
        popupButtonsControl.addComponent(historyBtn);
    }

    optionBtn.setContent(popupButtonsControl);

    if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED
            | (buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) {

        layout.addComponent(optionBtn);
    }

    ButtonGroup navigationBtns = new ButtonGroup();
    navigationBtns.setStyleName("navigation-btns");

    if ((buttonEnableFlags & PREVIOUS_BTN_PRESENTED) == PREVIOUS_BTN_PRESENTED) {
        Button previousItem = new Button(null, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireGotoPrevious(item);
            }
        });
        previousItem.setStyleName(UIConstants.THEME_GREEN_LINK);
        previousItem.setIcon(FontAwesome.CHEVRON_LEFT);
        previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM));
        navigationBtns.addButton(previousItem);
        previousItem.setEnabled(canRead);
    }

    if ((buttonEnableFlags & NEXT_BTN_PRESENTED) == NEXT_BTN_PRESENTED) {
        Button nextItemBtn = new Button(null, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                final T item = previewForm.getBean();
                previewForm.fireGotoNextItem(item);
            }
        });
        nextItemBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        nextItemBtn.setIcon(FontAwesome.CHEVRON_RIGHT);
        nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM));
        navigationBtns.addButton(nextItemBtn);
        nextItemBtn.setEnabled(canRead);
    }

    layout.addComponent(navigationBtns);

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.account.AccountContactListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();/*from  w ww .j  a v a2  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 = 1L;

        @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 = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final AccountContactSelectionWindow contactsWindow = new AccountContactSelectionWindow(
                    AccountContactListComp.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.account.AccountContactSelectionWindow.java

License:Open Source License

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

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

        @Override/*from www.  j  a  va2  s  .c  o m*/
        public void buttonClick(final ClickEvent event) {
            AccountContactSelectionWindow.this.close();
        }
    });
    selectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

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

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

    });

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

From source file:com.esofthead.mycollab.module.crm.view.account.AccountLeadListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");
    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();//from w  w w.  j av a 2  s. c  om
    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 AccountLeadSelectionWindow leadsWindow = new AccountLeadSelectionWindow(
                    AccountLeadListComp.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;
}

From source file:com.esofthead.mycollab.module.crm.view.account.AccountLeadSelectionWindow.java

License:Open Source License

@Override
protected void initUI() {
    tableItem = new LeadTableDisplay(LeadTableFieldDef.selected, Arrays.asList(LeadTableFieldDef.name,
            LeadTableFieldDef.title, LeadTableFieldDef.email, LeadTableFieldDef.phoneoffice));

    Button selectBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SELECT),
            new Button.ClickListener() {

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

    LeadSimpleSearchPanel leadSimpleSearchPanel = new LeadSimpleSearchPanel();
    leadSimpleSearchPanel.addSearchHandler(new SearchHandler<LeadSearchCriteria>() {

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

    });

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

From source file:com.esofthead.mycollab.module.crm.view.account.AccountListDashlet.java

License:Open Source License

public AccountListDashlet() {
    super("My Accounts", new VerticalLayout());
    tableItem = new AccountTableDisplay(Arrays.asList(AccountTableFieldDef.accountname,
            AccountTableFieldDef.phoneoffice, AccountTableFieldDef.email));

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

        @Override// w ww  . ja  va 2  s  .c  o m
        public void itemClick(final TableClickEvent event) {
            final SimpleAccount account = (SimpleAccount) event.getData();
            if ("accountname".equals(event.getFieldName())) {
                EventBusFactory.getInstance()
                        .post(new AccountEvent.GotoRead(AccountListDashlet.this, account.getId()));
            }
        }
    });
    bodyContent.addComponent(tableItem);

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

        @Override
        public void buttonClick(ClickEvent event) {
            UI.getCurrent()
                    .addWindow(new AccountListCustomizeWindow(AccountListDashlet.VIEW_DEF_ID, tableItem));

        }
    });
    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.account.AccountSearchPanel.java

License:Open Source License

private HorizontalLayout createSearchTopPanel() {
    final MHorizontalLayout layout = new MHorizontalLayout().withStyleName(UIConstants.HEADER_VIEW)
            .withWidth("100%").withSpacing(true).withMargin(new MarginInfo(true, false, true, false));

    final Label searchTitle = new CrmViewHeader(CrmTypeConstants.ACCOUNT,
            AppContext.getMessage(AccountI18nEnum.VIEW_LIST_TITLE));
    searchTitle.setStyleName(UIConstants.HEADER_TEXT);

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

    final Button createAccountBtn = new Button(AppContext.getMessage(AccountI18nEnum.BUTTON_NEW_ACCOUNT),
            new Button.ClickListener() {
                @Override//from ww  w .j a va 2 s . co  m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new AccountEvent.GotoAdd(this, null));
                }
            });
    createAccountBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_ACCOUNT));

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

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.account.AccountSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 3);
    layoutSearchPane.setSpacing(true);//from www.j a va2 s  . co m
    final ValueComboBox group = new ValueComboBox(false, "Name", "Email", "Website", "Phone",
            AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE));
    group.select("Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Email")) {
                addTextFieldSearch();
            } else if (searchType.equals("Website")) {
                addTextFieldSearch();
            } else if (searchType.equals("Phone")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

    layoutSearchPane.addComponent(group, 1, 0);
    layoutSearchPane.setComponentAlignment(group, Alignment.MIDDLE_CENTER);

    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.setDescription("Search");

    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            searchCriteria = new AccountSearchCriteria();
            searchCriteria.setSaccountid(new NumberSearchField(SearchField.AND, AppContext.getAccountId()));

            String searchType = (String) group.getValue();
            if (StringUtils.isNotBlank(searchType)) {

                if (textValueField != null) {
                    String strSearch = textValueField.getValue();
                    if (StringUtils.isNotBlank(strSearch)) {

                        if (searchType.equals("Name")) {
                            searchCriteria.setAccountname(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Email")) {
                            searchCriteria.setAnyMail(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Website")) {
                            searchCriteria.setWebsite(new StringSearchField(SearchField.AND, strSearch));
                        } else if (searchType.equals("Phone")) {
                            searchCriteria.setAnyPhone(new StringSearchField(SearchField.AND, strSearch));
                        }
                    }
                }

                if (userBox != null) {
                    String user = (String) userBox.getValue();
                    if (StringUtils.isNotBlank(user)) {
                        searchCriteria
                                .setAssignUsers(new SetSearchField<>(SearchField.AND, new String[] { user }));
                    }
                }
            }

            AccountSimpleSearchPanel.this.notifySearchHandler(searchCriteria);
        }
    });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
}

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

License:Open Source License

private void initContent() {
    MHorizontalLayout contentWrapper = new MHorizontalLayout().withSpacing(false).withWidth("100%");
    this.addComponent(contentWrapper);

    /* Content cheat */
    MVerticalLayout mainContent = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true))
            .withWidth("100%").withStyleName("readview-layout");
    contentWrapper.with(mainContent).expand(mainContent);

    MVerticalLayout rightColumn = new MVerticalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withWidth("250px");
    rightColumn.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    contentWrapper.addComponent(rightColumn);

    MHorizontalLayout actionPanel = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withWidth("100%").withStyleName(UIConstants.HEADER_VIEW);
    actionPanel.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Label headerText = new CrmViewHeader(CrmTypeConstants.ACTIVITY, "Calendar");
    headerText.setStyleName(UIConstants.HEADER_TEXT);
    actionPanel.with(headerText).expand(headerText);

    mainContent.addComponent(actionPanel);

    this.dateHdr = new Label();
    this.dateHdr.setSizeUndefined();
    this.dateHdr.setStyleName("h2");
    mainContent.addComponent(this.dateHdr);
    mainContent.setComponentAlignment(this.dateHdr, Alignment.MIDDLE_CENTER);

    toggleViewBtn = new PopupButton("Monthly");
    toggleViewBtn.setWidth("200px");
    toggleViewBtn.addStyleName("calendar-view-switcher");
    MVerticalLayout popupLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true))
            .withWidth("190px");

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

        @Override// www .j  a  v  a  2  s. c  o  m
        public void buttonClick(ClickEvent event) {
            toggleViewBtn.setPopupVisible(false);
            toggleViewBtn.setCaption(monthViewBtn.getCaption());
            calendarComponent.switchToMonthView(new Date(), true);
            datePicker.selectDate(new Date());
            monthViewBtn.addStyleName("selected-style");
            initLabelCaption();
        }
    });
    monthViewBtn.setStyleName("link");
    popupLayout.addComponent(monthViewBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            toggleViewBtn.setPopupVisible(false);
            toggleViewBtn.setCaption(weekViewBtn.getCaption());
            calendarComponent.switchToWeekView(new Date());
            datePicker.selectWeek(new Date());
        }
    });
    weekViewBtn.setStyleName("link");
    popupLayout.addComponent(weekViewBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            toggleViewBtn.setPopupVisible(false);
            toggleViewBtn.setCaption(dailyViewBtn.getCaption());
            Date currentDate = new Date();
            datePicker.selectDate(currentDate);
            calendarComponent.switchToDateView(currentDate);
        }
    });
    dailyViewBtn.setStyleName("link");
    popupLayout.addComponent(dailyViewBtn);

    toggleViewBtn.setContent(popupLayout);
    CssLayout toggleBtnWrap = new CssLayout();
    toggleBtnWrap.setStyleName("switcher-wrap");
    toggleBtnWrap.addComponent(toggleViewBtn);

    rightColumn.addComponent(toggleBtnWrap);
    rightColumn.setComponentAlignment(toggleBtnWrap, Alignment.MIDDLE_CENTER);

    rightColumn.addComponent(this.datePicker);
    initLabelCaption();
    addCalendarEvent();

    actionPanel.addComponent(calendarActionBtn);
    actionPanel.setComponentAlignment(calendarActionBtn, Alignment.MIDDLE_RIGHT);

    VerticalLayout actionBtnLayout = new VerticalLayout();
    actionBtnLayout.setMargin(true);
    actionBtnLayout.setSpacing(true);
    actionBtnLayout.setWidth("150px");

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

        @Override
        public void buttonClick(ClickEvent event) {
            calendarActionBtn.setPopupVisible(false);
            String caption = event.getButton().getCaption();
            if (caption.equals("New Task")) {
                EventBusFactory.getInstance().post(new ActivityEvent.TaskAdd(this, null));
            } else if (caption.equals("New Call")) {
                EventBusFactory.getInstance().post(new ActivityEvent.CallAdd(this, null));
            } else if (caption.equals("New Event")) {
                EventBusFactory.getInstance().post(new ActivityEvent.MeetingAdd(this, null));
            }
        }
    };

    ButtonLink todoBtn = new ButtonLink("New Task", listener);
    actionBtnLayout.addComponent(todoBtn);
    todoBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK));
    todoBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_TASK));

    Button callBtn = new ButtonLink("New Call", listener);
    actionBtnLayout.addComponent(callBtn);
    callBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL));
    callBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL));

    ButtonLink meetingBtn = new ButtonLink("New Meeting", listener);
    actionBtnLayout.addComponent(meetingBtn);
    meetingBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING));
    meetingBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_MEETING));

    calendarActionBtn.setContent(actionBtnLayout);

    ButtonGroup viewSwitcher = new ButtonGroup();

    Button calendarViewBtn = new Button("Calendar");
    calendarViewBtn.setStyleName("selected");
    calendarViewBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    viewSwitcher.addButton(calendarViewBtn);

    Button activityListBtn = new Button("Activities", new Button.ClickListener() {
        private static final long serialVersionUID = 2156576556541398934L;

        @Override
        public void buttonClick(ClickEvent evt) {
            ActivitySearchCriteria criteria = new ActivitySearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            EventBusFactory.getInstance().post(new ActivityEvent.GotoTodoList(this, null));
        }
    });
    activityListBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    viewSwitcher.addButton(activityListBtn);

    actionPanel.addComponent(viewSwitcher);
    actionPanel.setComponentAlignment(viewSwitcher, Alignment.MIDDLE_RIGHT);

    calendarComponent = new CalendarDisplay();
    mainContent.addComponent(calendarComponent);
    mainContent.setExpandRatio(calendarComponent, 1);
    mainContent.setComponentAlignment(calendarComponent, Alignment.MIDDLE_CENTER);

    HorizontalLayout spacing = new HorizontalLayout();
    spacing.setHeight("30px");
    mainContent.addComponent(spacing);

    HorizontalLayout noteInfoLayout = new HorizontalLayout();
    noteInfoLayout.setSpacing(true);

    HorizontalLayout noteWapper = new HorizontalLayout();
    noteWapper.setHeight("30px");
    Label noteLbl = new Label("Note:");
    noteWapper.addComponent(noteLbl);
    noteWapper.setComponentAlignment(noteLbl, Alignment.MIDDLE_CENTER);
    noteInfoLayout.addComponent(noteWapper);

    HorizontalLayout completeWapper = new HorizontalLayout();
    completeWapper.setWidth("100px");
    completeWapper.setHeight("30px");
    completeWapper.addStyleName("eventLblcompleted");
    Label completeLabel = new Label("Completed");
    completeWapper.addComponent(completeLabel);
    completeWapper.setComponentAlignment(completeLabel, Alignment.MIDDLE_CENTER);
    noteInfoLayout.addComponent(completeWapper);

    HorizontalLayout overdueWapper = new HorizontalLayout();
    overdueWapper.setWidth("100px");
    overdueWapper.setHeight("30px");
    overdueWapper.addStyleName("eventLbloverdue");
    Label overdueLabel = new Label("Overdue");
    overdueWapper.addComponent(overdueLabel);
    overdueWapper.setComponentAlignment(overdueLabel, Alignment.MIDDLE_CENTER);
    noteInfoLayout.addComponent(overdueWapper);

    HorizontalLayout futureWapper = new HorizontalLayout();
    futureWapper.setWidth("100px");
    futureWapper.setHeight("30px");
    futureWapper.addStyleName("eventLblfuture");
    Label futureLabel = new Label("Future");
    futureWapper.addComponent(futureLabel);
    futureWapper.setComponentAlignment(futureLabel, Alignment.MIDDLE_CENTER);
    noteInfoLayout.addComponent(futureWapper);

    mainContent.addComponent(noteInfoLayout);
    mainContent.setComponentAlignment(noteInfoLayout, Alignment.MIDDLE_CENTER);
}

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);//  ww  w  .  j a  va2 s  . c  o  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);
}