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.mechanicshop.components.TableLayout.java

public void createCustomMessage() {
    final TextArea textArea = new TextArea();
    textArea.setImmediate(true);//from  w ww . j  a v a 2s .co m
    textArea.setColumns(30);
    textArea.setRows(10);
    textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
    textArea.setRequired(true);
    final Window subWindow = new Window();
    subWindow.setModal(true);
    subWindow.setHeight("350px");
    subWindow.setWidth("500px");
    subWindow.setCaption("Insert Message");
    subWindow.setStyleName(ValoTheme.WINDOW_TOP_TOOLBAR);
    subWindow.setClosable(false);
    subWindow.setResizable(false);

    HorizontalLayout layoutButtons = new HorizontalLayout();
    layoutButtons.setMargin(false);
    Button sendBtn = new Button("Send");
    sendBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                textArea.validate();
                String message = textArea.getValue();
                smsSenderService.sendMessageMassive(message);
                subWindow.close();
                Notification.show("Message Sent");
            } catch (Exception e) {

            }
        }
    });
    sendBtn.setImmediate(true);
    sendBtn.setStyleName(ValoTheme.BUTTON_TINY);
    sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    Button cancelBtn = new Button("Cancel");
    cancelBtn.setStyleName(ValoTheme.BUTTON_TINY);
    cancelBtn.addStyleName(ValoTheme.BUTTON_DANGER);
    cancelBtn.setImmediate(true);
    cancelBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            subWindow.close();

        }
    });

    layoutButtons.setSizeUndefined();
    layoutButtons.setSpacing(true);
    layoutButtons.addComponents(cancelBtn, sendBtn);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.addComponent(textArea);
    layout.addComponent(layoutButtons);
    layout.setComponentAlignment(textArea, Alignment.MIDDLE_CENTER);
    layout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_RIGHT);
    layout.setExpandRatio(textArea, 3);

    layout.setSizeFull();

    subWindow.setContent(layout);
    subWindow.center();

    getUI().addWindow(subWindow);
}

From source file:com.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()));

    tableItem.addGeneratedColumn("contactName", (source, itemId, columnId) -> {
        final SimpleContact contact = tableItem.getBeanByIndex(itemId);

        return new ELabel(contact.getContactName()).withStyleName(WebThemes.BUTTON_LINK)
                .withDescription(CrmTooltipGenerator.generateToolTipContact(UserUIContext.getUserLocale(),
                        MyCollabUI.getDateFormat(), contact, MyCollabUI.getSiteUrl(),
                        UserUIContext.getUserTimeZone()));
    });/*from www.  jav  a2 s  .c o  m*/

    Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
            clickEvent -> close());
    selectBtn.setStyleName(WebThemes.BUTTON_ACTION);

    ContactSearchPanel contactSimpleSearchPanel = new ContactSearchPanel();
    contactSimpleSearchPanel.addSearchHandler(criteria -> tableItem.setSearchCriteria(criteria));

    this.bodyContent.with(contactSimpleSearchPanel, selectBtn, tableItem);
}

From source file:com.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(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
            clickEvent -> close());//from   w  ww  . j a  v  a 2  s .c  o  m
    selectBtn.setStyleName(WebUIConstants.BUTTON_ACTION);

    LeadSearchPanel leadSimpleSearchPanel = new LeadSearchPanel();
    leadSimpleSearchPanel.addSearchHandler(criteria -> tableItem.setSearchCriteria(criteria));

    this.bodyContent.with(leadSimpleSearchPanel, selectBtn, tableItem);
}

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

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPanel = new GridLayout(3, 3);
    layoutSearchPanel.setSpacing(true);//from   w  ww .ja  v  a2  s .  c o  m
    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();
            }
        }
    });

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

    addTextFieldSearch();

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

    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            doSearch();
        }
    });
    layoutSearchPanel.addComponent(searchBtn, 2, 0);
    layoutSearchPanel.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPanel);
}

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();// w  w  w  .j  a v  a  2  s.c om
    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.activity.ActivitySearchPanel.java

License:Open Source License

@Override
protected Component buildExtraControls() {
    final SplitButton splitBtn = new SplitButton();
    splitBtn.setSizeUndefined();//w w  w . j a v a 2s.co  m
    splitBtn.setEnabled(UserUIContext.canWrite(RolePermissionCollections.CRM_CALL)
            || UserUIContext.canWrite(RolePermissionCollections.CRM_MEETING));
    splitBtn.addStyleName(WebThemes.BUTTON_ACTION);
    splitBtn.setIcon(FontAwesome.PLUS);
    splitBtn.setCaption(UserUIContext.getMessage(TaskI18nEnum.NEW));
    splitBtn.addClickListener(
            event -> EventBusFactory.getInstance().post(new ActivityEvent.TaskAdd(this, null)));

    OptionPopupContent btnControlsLayout = new OptionPopupContent();
    splitBtn.setContent(btnControlsLayout);

    Button createMeetingBtn = new Button(UserUIContext.getMessage(MeetingI18nEnum.NEW), clickEvent -> {
        splitBtn.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ActivityEvent.MeetingAdd(this, null));
    });
    btnControlsLayout.addOption(createMeetingBtn);
    createMeetingBtn.setEnabled(UserUIContext.canWrite(RolePermissionCollections.CRM_MEETING));
    final Button createCallBtn = new Button(UserUIContext.getMessage(CallI18nEnum.NEW), clickEvent -> {
        splitBtn.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ActivityEvent.CallAdd(this, null));
    });
    createCallBtn.setEnabled(UserUIContext.canWrite(RolePermissionCollections.CRM_CALL));
    btnControlsLayout.addOption(createCallBtn);

    ButtonGroup viewSwitcher = new ButtonGroup();

    Button calendarViewBtn = new Button("Calendar",
            clickEvent -> EventBusFactory.getInstance().post(new ActivityEvent.GotoCalendar(this, null)));
    calendarViewBtn.addStyleName(WebThemes.BUTTON_ACTION);
    viewSwitcher.addButton(calendarViewBtn);

    Button activityListBtn = new Button("Activities");
    activityListBtn.setStyleName("selected");
    activityListBtn.addStyleName(WebThemes.BUTTON_ACTION);
    viewSwitcher.addButton(activityListBtn);

    return new MHorizontalLayout(splitBtn, viewSwitcher);
}

From source file:com.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/* ww  w .  j a  va 2 s.  c o m*/
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    selectBtn.setStyleName(UIConstants.BUTTON_ACTION);

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

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

    });

    this.bodyContent.with(accountSimpleSearchPanel, selectBtn, tableItem);
}

From source file:com.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   ww  w. j  av  a  2s .  c  o m*/
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    selectBtn.setStyleName(UIConstants.BUTTON_ACTION);

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

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

    });

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

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

License:Open Source License

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

    Button selectBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_SELECT),
            clickEvent -> close());/*from   www  .  j  a  v a2  s. c om*/
    selectBtn.setStyleName(WebUIConstants.BUTTON_ACTION);

    LeadSearchPanel searchPanel = new LeadSearchPanel();
    searchPanel.addSearchHandler(criteria -> tableItem.setSearchCriteria(criteria));

    bodyContent.with(searchPanel, selectBtn, tableItem);
}

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

License:Open Source License

private void createBasicSearchLayout() {
    layoutSearchPane = new GridLayout(3, 2);
    layoutSearchPane.setSpacing(true);/* w  ww . j  a v a 2 s.  c o m*/

    group = new ValueComboBox(false, "Campaign Name", "Start Date", "End Date");
    group.select("Campaign Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Campaign Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Start Date")) {
                addDateFieldSearch();
            } else if (searchType.equals("End Date")) {
                addDateFieldSearch();
            }
        }
    });

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

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            doSearch();
        }
    });
    layoutSearchPane.addComponent(searchBtn, 2, 0);
    layoutSearchPane.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(layoutSearchPane);
}