Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT

Introduction

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

Prototype

Alignment MIDDLE_RIGHT

To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.

Click Source Link

Usage

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

License:Open Source License

public CrmActivityComponent(String type) {
    withMargin(false).withStyleName("activity-comp");
    this.type = type;
    this.groupFormatter = AuditLogRegistry.getFieldGroupFormatterOfType(type);
    headerLbl = new ELabel("");

    final OptionGroup sortDirection = new OptionGroup();
    sortDirection.addStyleName("sortDirection");
    String oldestFirstDirection = UserUIContext.getMessage(GenericI18Enum.OPT_OLDEST_FIRST);
    final String newestFirstDirection = UserUIContext.getMessage(GenericI18Enum.OPT_NEWEST_FIRST);
    sortDirection.addItems(newestFirstDirection, oldestFirstDirection);
    sortDirection.setValue(newestFirstDirection);
    sortDirection.addValueChangeListener(valueChangeEvent -> {
        Object value = sortDirection.getValue();
        isAscending = newestFirstDirection.equals(value);
        displayActivities();/*  w  w w .j a va  2  s  .  c o m*/
    });

    MHorizontalLayout headerPanel = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, true))
            .withStyleName(WebThemes.FORM_SECTION, WebThemes.HOVER_EFFECT_NOT_BOX).withFullWidth()
            .with(headerLbl, sortDirection).withAlign(headerLbl, Alignment.MIDDLE_LEFT)
            .withAlign(sortDirection, Alignment.MIDDLE_RIGHT);

    commentBox = new CrmCommentInput(this, type);
    activityBox = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, false));
    this.with(headerPanel, commentBox, activityBox);

    commentService = AppContextUtil.getSpringBean(CommentService.class);
    auditLogService = AppContextUtil.getSpringBean(AuditLogService.class);
}

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

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CONTACT)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(ContactI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        final MButton selectBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
                clickEvent -> {/*from ww  w  . j a v  a2  s .  co  m*/
                    final AccountContactSelectionWindow contactsWindow = new AccountContactSelectionWindow(
                            AccountContactListComp.this);
                    final ContactSearchCriteria criteria = new ContactSearchCriteria();
                    criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
                    UI.getCurrent().addWindow(contactsWindow);
                    contactsWindow.setSearchCriteria(criteria);
                    controlsBtn.setPopupVisible(false);
                }).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));

        OptionPopupContent buttonControlLayout = new OptionPopupContent();
        buttonControlLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlLayout);

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

    return controlsBtnWrap;
}

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

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_LEAD)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(LeadI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        MButton selectBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT), clickEvent -> {
            AccountLeadSelectionWindow leadsWindow = new AccountLeadSelectionWindow(AccountLeadListComp.this);
            LeadSearchCriteria criteria = new LeadSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
            UI.getCurrent().addWindow(leadsWindow);
            leadsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD));

        OptionPopupContent buttonControlLayout = new OptionPopupContent();
        buttonControlLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlLayout);

        controlsBtnWrap.addComponent(controlsBtn);
        controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    }//from   w  w w. ja  va 2 s .  c  om
    return controlsBtnWrap;
}

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

License:Open Source License

private void initContent() {
    MHorizontalLayout contentWrapper = new MHorizontalLayout().withSpacing(false).withFullWidth();
    this.addComponent(contentWrapper);

    /* Content cheat */
    MVerticalLayout mainContent = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true))
            .withFullWidth().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))
            .withFullWidth().withStyleName(WebThemes.HEADER_VIEW);
    actionPanel.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    Component headerText = ComponentUtils.header(CrmTypeConstants.ACTIVITY, "Calendar");
    actionPanel.with(headerText).expand(headerText);

    mainContent.addComponent(actionPanel);

    dateHdr = new Label();
    dateHdr.setSizeUndefined();/*from  www  . j a v a  2s . c o m*/
    dateHdr.setStyleName(ValoTheme.LABEL_H3);
    mainContent.addComponent(this.dateHdr);
    mainContent.setComponentAlignment(this.dateHdr, Alignment.MIDDLE_CENTER);

    toggleViewBtn = new PopupButton(UserUIContext.getMessage(DayI18nEnum.OPT_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(UserUIContext.getMessage(DayI18nEnum.OPT_MONTHLY), clickEvent -> {
        toggleViewBtn.setPopupVisible(false);
        toggleViewBtn.setCaption(monthViewBtn.getCaption());
        calendarComponent.switchToMonthView(new Date(), true);
        datePicker.selectDate(new Date());
        monthViewBtn.addStyleName("selected-style");
        initLabelCaption();
    });
    monthViewBtn.setStyleName(WebThemes.BUTTON_LINK);
    popupLayout.addComponent(monthViewBtn);

    weekViewBtn = new Button(UserUIContext.getMessage(DayI18nEnum.OPT_WEEKLY), clickEvent -> {
        toggleViewBtn.setPopupVisible(false);
        toggleViewBtn.setCaption(weekViewBtn.getCaption());
        calendarComponent.switchToWeekView(new Date());
        datePicker.selectWeek(new Date());
    });
    weekViewBtn.setStyleName(WebThemes.BUTTON_LINK);
    popupLayout.addComponent(weekViewBtn);

    dailyViewBtn = new Button(UserUIContext.getMessage(DayI18nEnum.OPT_DAILY), clickEvent -> {
        toggleViewBtn.setPopupVisible(false);
        toggleViewBtn.setCaption(dailyViewBtn.getCaption());
        Date currentDate = new Date();
        datePicker.selectDate(currentDate);
        calendarComponent.switchToDateView(currentDate);
    });
    dailyViewBtn.setStyleName(WebThemes.BUTTON_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);

    OptionPopupContent actionBtnLayout = new OptionPopupContent();

    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 Meeting")) {
                EventBusFactory.getInstance().post(new ActivityEvent.MeetingAdd(this, null));
            }
        }
    };

    MButton todoBtn = new MButton(UserUIContext.getMessage(TaskI18nEnum.NEW), listener)
            .withStyleName(WebThemes.BUTTON_LINK).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK))
            .withVisible(UserUIContext.canWrite(RolePermissionCollections.CRM_TASK));
    actionBtnLayout.addOption(todoBtn);

    MButton callBtn = new MButton(UserUIContext.getMessage(MeetingI18nEnum.NEW), listener)
            .withStyleName(WebThemes.BUTTON_LINK).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL))
            .withVisible(UserUIContext.canWrite(RolePermissionCollections.CRM_CALL));
    actionBtnLayout.addOption(callBtn);

    MButton meetingBtn = new MButton(UserUIContext.getMessage(MeetingI18nEnum.NEW), listener)
            .withStyleName(WebThemes.BUTTON_LINK).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING))
            .withVisible(UserUIContext.canWrite(RolePermissionCollections.CRM_MEETING));
    actionBtnLayout.addOption(meetingBtn);

    calendarActionBtn.setContent(actionBtnLayout);

    ButtonGroup viewSwitcher = new ButtonGroup();

    Button calendarViewBtn = new Button("Calendar");
    calendarViewBtn.setStyleName("selected");
    calendarViewBtn.addStyleName(WebThemes.BUTTON_ACTION);
    viewSwitcher.addButton(calendarViewBtn);

    Button activityListBtn = new Button("Activities", event -> {
        ActivitySearchCriteria criteria = new ActivitySearchCriteria();
        criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
        EventBusFactory.getInstance().post(new ActivityEvent.GotoTodoList(this, null));
    });
    activityListBtn.addStyleName(WebThemes.BUTTON_ACTION);
    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(UserUIContext.getMessage(GenericI18Enum.OPT_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.mycollab.module.crm.view.campaign.CampaignAccountListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_ACCOUNT)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(AccountI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        final Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
                clickEvent -> {/*  ww  w. j  a  va  2  s  . c o  m*/
                    final CampaignAccountSelectionWindow accountsWindow = new CampaignAccountSelectionWindow(
                            CampaignAccountListComp.this);
                    final AccountSearchCriteria criteria = new AccountSearchCriteria();
                    criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
                    UI.getCurrent().addWindow(accountsWindow);
                    accountsWindow.setSearchCriteria(criteria);
                    controlsBtn.setPopupVisible(false);
                });
        selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT));
        OptionPopupContent buttonControlLayout = new OptionPopupContent();
        buttonControlLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlLayout);

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

    return controlsBtnWrap;
}

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

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CONTACT)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(ContactI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        final Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
                clickEvent -> {/*from  ww w  .j a v  a2  s  .c o m*/
                    final CampaignContactSelectionWindow contactsWindow = new CampaignContactSelectionWindow(
                            CampaignContactListComp.this);
                    final ContactSearchCriteria criteria = new ContactSearchCriteria();
                    criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
                    UI.getCurrent().addWindow(contactsWindow);
                    contactsWindow.setSearchCriteria(criteria);
                    controlsBtn.setPopupVisible(false);
                });
        selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
        OptionPopupContent buttonControlLayout = new OptionPopupContent();
        buttonControlLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlLayout);

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

    return controlsBtnWrap;
}

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

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_LEAD)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(LeadI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        final Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
                clickEvent -> {//from  w w w.j a va  2s  . co m
                    CampaignLeadSelectionWindow leadsWindow = new CampaignLeadSelectionWindow(
                            CampaignLeadListComp.this);
                    LeadSearchCriteria criteria = new LeadSearchCriteria();
                    criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
                    UI.getCurrent().addWindow(leadsWindow);
                    leadsWindow.setSearchCriteria(criteria);
                    controlsBtn.setPopupVisible(false);
                });
        selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD));
        OptionPopupContent buttonControlLayout = new OptionPopupContent();
        buttonControlLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlLayout);

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

    return controlsBtnWrap;
}

From source file:com.mycollab.module.crm.view.cases.CaseContactListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CONTACT)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(ContactI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT), clickEvent -> {
            CaseContactSelectionWindow contactsWindow = new CaseContactSelectionWindow(
                    CaseContactListComp.this);
            ContactSearchCriteria criteria = new ContactSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
            UI.getCurrent().addWindow(contactsWindow);
            contactsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        });//from   w  w w .j a v  a 2s. c  om
        selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
        OptionPopupContent buttonControlsLayout = new OptionPopupContent();
        buttonControlsLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlsLayout);

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

    return controlsBtnWrap;
}

From source file:com.mycollab.module.crm.view.contact.ContactOpportunityListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlsBtnWrap = new VerticalLayout();
    controlsBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(OpportunityI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        controlsBtn.setSizeUndefined();/*w  w  w.java  2  s  .  co  m*/
        MButton selectBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT), clickEvent -> {
            ContactOpportunitySelectionWindow opportunitiesWindow = new ContactOpportunitySelectionWindow(
                    ContactOpportunityListComp.this);
            OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
            criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
            UI.getCurrent().addWindow(opportunitiesWindow);
            opportunitiesWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }).withIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));

        OptionPopupContent buttonControlsLayout = new OptionPopupContent();
        buttonControlsLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlsLayout);
        controlsBtnWrap.addComponent(controlsBtn);
        controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    }
    return controlsBtnWrap;
}

From source file:com.mycollab.module.crm.view.lead.LeadCampaignListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    VerticalLayout controlBtnWrap = new VerticalLayout();
    controlBtnWrap.setWidth("100%");

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_CAMPAIGN)) {
        final SplitButton controlsBtn = new SplitButton();
        controlsBtn.setSizeUndefined();//w w  w.  j a v  a 2  s .c om
        controlsBtn.addStyleName(WebThemes.BUTTON_ACTION);
        controlsBtn.setCaption(UserUIContext.getMessage(CampaignI18nEnum.NEW));
        controlsBtn.setIcon(FontAwesome.PLUS);
        controlsBtn.addClickListener(event -> fireNewRelatedItem(""));
        Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT), clickEvent -> {
            LeadCampaignSelectionWindow leadsWindow = new LeadCampaignSelectionWindow(
                    LeadCampaignListComp.this);
            CampaignSearchCriteria criteria = new CampaignSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
            UI.getCurrent().addWindow(leadsWindow);
            leadsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        });
        selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CAMPAIGN));
        OptionPopupContent buttonControlsLayout = new OptionPopupContent();
        buttonControlsLayout.addOption(selectBtn);
        controlsBtn.setContent(buttonControlsLayout);

        controlBtnWrap.addComponent(controlsBtn);
        controlBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    }

    return controlBtnWrap;
}