Example usage for com.vaadin.ui Button setEnabled

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

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

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

License:Open Source License

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

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.CAMPAIGN,
            AppContext.getMessage(CampaignI18nEnum.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(CampaignI18nEnum.BUTTON_NEW_CAMPAIGN),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//from  w w w  .  j av a2 s.  c  o  m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new CampaignEvent.GotoAdd(this, null));

                }
            });
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CAMPAIGN));
    layout.with(createAccountBtn).withAlign(createAccountBtn, Alignment.MIDDLE_RIGHT);
    return layout;
}

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

License:Open Source License

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

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.CASE,
            AppContext.getMessage(CaseI18nEnum.VIEW_LIST_TITLE));
    searchtitle.setStyleName(UIConstants.HEADER_TEXT);

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

    final Button createAccountBtn = new Button(AppContext.getMessage(CaseI18nEnum.BUTTON_NEW_CASE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//  ww  w  .j  a  v  a2s .c o m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new CaseEvent.GotoAdd(this, null));
                }
            });
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE));
    layout.with(createAccountBtn).withAlign(createAccountBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.contact.ContactSearchPanel.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.CONTACT,
            AppContext.getMessage(ContactI18nEnum.VIEW_LIST_TITLE));
    searchtitle.setStyleName(UIConstants.HEADER_TEXT);
    layout.with(searchtitle).withAlign(searchtitle, Alignment.MIDDLE_LEFT).expand(searchtitle);

    final Button createBtn = new Button(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override/*w  w w  .  j  av a2 s . c  o m*/
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new ContactEvent.GotoAdd(this, null));
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    layout.with(createBtn).withAlign(createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

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

License:Open Source License

public CrmToolbar() {
    super();//from   w  w w  . j  a v a  2s .c om
    this.setStyleName("crm-toolbar");
    this.setWidth("100%");
    this.setMargin(new MarginInfo(false, true, false, true));
    final NavigatorItemListener listener = new NavigatorItemListener();
    final Button homeBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DASHBOARD_HEADER),
            listener);
    homeBtn.setStyleName("link");
    addComponent(homeBtn);

    final Button accountList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACCOUNTS_HEADER),
            listener);
    accountList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_ACCOUNT));
    accountList.setStyleName("link");
    addComponent(accountList);

    final Button contactList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CONTACTS_HEADER),
            listener);
    contactList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CONTACT));
    contactList.setStyleName("link");
    addComponent(contactList);

    final Button campaignList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CAMPAIGNS_HEADER),
            listener);
    campaignList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CAMPAIGN));
    campaignList.setStyleName("link");
    addComponent(campaignList);

    final Button leadList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_LEADS_HEADER), listener);
    leadList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_LEAD));
    leadList.setStyleName("link");
    addComponent(leadList);

    final Button opportunityList = new Button(
            AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_OPPORTUNTIES_HEADER), listener);
    opportunityList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_OPPORTUNITY));
    opportunityList.setStyleName("link");
    addComponent(opportunityList);

    final Button caseList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CASES_HEADER), listener);
    caseList.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_CASE));
    caseList.setStyleName("link");
    addComponent(caseList);

    final Button activitiesList = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_ACTIVITIES_HEADER),
            listener);
    final boolean isActivityEnable = AppContext.canRead(RolePermissionCollections.CRM_MEETING)
            || AppContext.canRead(RolePermissionCollections.CRM_TASK)
            || AppContext.canRead(RolePermissionCollections.CRM_CALL);
    activitiesList.setEnabled(isActivityEnable);
    activitiesList.setStyleName("link");
    addComponent(activitiesList);

    addStyleName("h-sidebar-menu");

    final Button fileBtn = new Button(AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_DOCUMENT_HEADER),
            listener);
    fileBtn.setEnabled(AppContext.canRead(RolePermissionCollections.CRM_DOCUMENT));
    fileBtn.setStyleName("link");
    addComponent(fileBtn);

    final Button notificationBtn = new Button(
            AppContext.getMessage(CrmCommonI18nEnum.TOOLBAR_CRMNOTIFICATION_HEADER), listener);
    notificationBtn.setStyleName("link");
    addComponent(notificationBtn);

    addBtn = new PopupButton(AppContext.getMessage(CrmCommonI18nEnum.BUTTON_CREATE));
    final GridLayout addBtnLayout = new GridLayout(3, 2);
    addBtnLayout.setMargin(true);
    addBtnLayout.setWidth("370px");
    addBtnLayout.setSpacing(true);

    final ButtonLink newAccountBtn = new ButtonLink(AppContext.getMessage(AccountI18nEnum.BUTTON_NEW_ACCOUNT),
            listener, false);
    newAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_ACCOUNT));
    newAccountBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT));
    addBtnLayout.addComponent(newAccountBtn);

    final ButtonLink newContactBtn = new ButtonLink(AppContext.getMessage(ContactI18nEnum.BUTTON_NEW_CONTACT),
            listener, false);
    newContactBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    newContactBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CONTACT));
    addBtnLayout.addComponent(newContactBtn);

    final ButtonLink newCampaignBtn = new ButtonLink(
            AppContext.getMessage(CampaignI18nEnum.BUTTON_NEW_CAMPAIGN), listener, false);
    newCampaignBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CAMPAIGN));
    newCampaignBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CAMPAIGN));
    addBtnLayout.addComponent(newCampaignBtn);

    final ButtonLink newOpportunityBtn = new ButtonLink(
            AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY), listener, false);
    newOpportunityBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));
    newOpportunityBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY));
    addBtnLayout.addComponent(newOpportunityBtn);

    final ButtonLink newLeadBtn = new ButtonLink(AppContext.getMessage(LeadI18nEnum.BUTTON_NEW_LEAD), listener,
            false);
    newLeadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_LEAD));
    newLeadBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.LEAD));
    addBtnLayout.addComponent(newLeadBtn);

    final ButtonLink newCaseBtn = new ButtonLink(AppContext.getMessage(CaseI18nEnum.BUTTON_NEW_CASE), listener,
            false);
    newCaseBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CASE));
    newCaseBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CASE));
    addBtnLayout.addComponent(newCaseBtn);

    final ButtonLink newTaskBtn = new ButtonLink(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), listener,
            false);
    newTaskBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_TASK));
    newTaskBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.TASK));
    addBtnLayout.addComponent(newTaskBtn);

    final ButtonLink newCallBtn = new ButtonLink(AppContext.getMessage(CallI18nEnum.BUTTON_NEW_CALL), listener,
            false);
    newCallBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CALL));
    newCallBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.CALL));
    addBtnLayout.addComponent(newCallBtn);

    final ButtonLink newMeetingBtn = new ButtonLink(AppContext.getMessage(MeetingI18nEnum.BUTTON_NEW_MEETING),
            listener, false);
    newMeetingBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_MEETING));
    newMeetingBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.MEETING));
    addBtnLayout.addComponent(newMeetingBtn);

    addBtn.setContent(addBtnLayout);
    addBtn.setStyleName("link");
    addBtn.addStyleName("quickadd-btn");
    addComponent(addBtn);

    setExpandRatio(addBtn, 1.0f);
    setComponentAlignment(addBtn, Alignment.MIDDLE_RIGHT);
}

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

License:Open Source License

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

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.LEAD,
            AppContext.getMessage(LeadI18nEnum.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(LeadI18nEnum.BUTTON_NEW_LEAD),
            new Button.ClickListener() {

                @Override// w w  w. jav a 2s.  c o  m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new LeadEvent.GotoAdd(this, null));
                }
            });
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_LEAD));

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

    return layout;
}

From source file:com.esofthead.mycollab.module.crm.view.opportunity.OpportunitySearchPanel.java

License:Open Source License

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

    final Label searchtitle = new CrmViewHeader(CrmTypeConstants.OPPORTUNITY,
            AppContext.getMessage(OpportunityI18nEnum.VIEW_LIST_TITLE));
    searchtitle.setStyleName(UIConstants.HEADER_TEXT);
    layout.with(searchtitle).expand(searchtitle).withAlign(searchtitle, Alignment.MIDDLE_LEFT);

    final Button createAccountBtn = new Button(
            AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override/*from   w w w.  j  a  v a 2 s .c  o  m*/
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new OpportunityEvent.GotoAdd(OpportunitySearchPanel.this, null));
                }
            });
    createAccountBtn.setIcon(FontAwesome.PLUS);
    createAccountBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    createAccountBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY));
    layout.with(createAccountBtn).withAlign(createAccountBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.esofthead.mycollab.module.file.view.components.ResourcesDisplayComponent.java

License:Open Source License

public ResourcesDisplayComponent(final String rootPath, final Folder rootFolder) {
    this.setSpacing(true);
    this.baseFolder = rootFolder;
    this.rootPath = rootPath;
    externalResourceService = ApplicationContextUtil.getSpringBean(ExternalResourceService.class);
    externalDriveService = ApplicationContextUtil.getSpringBean(ExternalDriveService.class);
    resourceService = ApplicationContextUtil.getSpringBean(ResourceService.class);

    VerticalLayout mainBodyLayout = new VerticalLayout();
    mainBodyLayout.setSpacing(true);//from w  ww .j  a v  a2  s .  c om
    mainBodyLayout.addStyleName("box-no-border-left");

    // file breadcrum ---------------------
    HorizontalLayout breadcrumbContainer = new HorizontalLayout();
    breadcrumbContainer.setMargin(false);
    fileBreadCrumb = new FileBreadcrumb(rootPath);
    breadcrumbContainer.addComponent(fileBreadCrumb);
    mainBodyLayout.addComponent(breadcrumbContainer);

    // Construct controllGroupBtn
    controllGroupBtn = new MHorizontalLayout().withMargin(new MarginInfo(false, false, false, true));

    final Button selectAllBtn = new Button();
    selectAllBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    selectAllBtn.setIcon(FontAwesome.SQUARE_O);
    selectAllBtn.setData(false);
    selectAllBtn.setImmediate(true);
    selectAllBtn.setDescription("Select all");

    selectAllBtn.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (!(Boolean) selectAllBtn.getData()) {
                selectAllBtn.setIcon(FontAwesome.CHECK_SQUARE_O);
                selectAllBtn.setData(true);
                resourcesContainer.setAllValues(true);
            } else {
                selectAllBtn.setData(false);
                selectAllBtn.setIcon(FontAwesome.SQUARE_O);
                resourcesContainer.setAllValues(false);
            }
        }
    });
    controllGroupBtn.with(selectAllBtn).withAlign(selectAllBtn, Alignment.MIDDLE_LEFT);

    Button goUpBtn = new Button("Up");
    goUpBtn.setIcon(FontAwesome.ARROW_UP);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Folder parentFolder;
            if (baseFolder instanceof ExternalFolder) {
                if (baseFolder.getPath().equals("/")) {
                    parentFolder = baseFolder;
                } else {
                    parentFolder = externalResourceService.getParentResourceFolder(
                            ((ExternalFolder) baseFolder).getExternalDrive(), baseFolder.getPath());
                }
            } else if (!baseFolder.getPath().equals(rootPath)) {
                parentFolder = resourceService.getParentFolder(baseFolder.getPath());
            } else {
                parentFolder = baseFolder;
            }

            resourcesContainer.constructBody(parentFolder);
            baseFolder = parentFolder;
            fileBreadCrumb.gotoFolder(baseFolder);
        }
    });
    goUpBtn.setDescription("Back to parent folder");
    goUpBtn.setStyleName(UIConstants.THEME_BROWN_LINK);
    goUpBtn.setDescription("Go up");

    controllGroupBtn.with(goUpBtn).withAlign(goUpBtn, Alignment.MIDDLE_LEFT);

    ButtonGroup navButton = new ButtonGroup();
    navButton.addStyleName(UIConstants.THEME_BROWN_LINK);
    Button createBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CREATE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    AddNewFolderWindow addnewFolderWindow = new AddNewFolderWindow();
                    UI.getCurrent().addWindow(addnewFolderWindow);
                }
            });
    createBtn.setIcon(FontAwesome.PLUS);
    createBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    createBtn.setDescription("Create new folder");
    createBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(createBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            MultiUploadContentWindow multiUploadWindow = new MultiUploadContentWindow();
            UI.getCurrent().addWindow(multiUploadWindow);
        }
    });
    uploadBtn.setIcon(FontAwesome.UPLOAD);
    uploadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    uploadBtn.setDescription("Upload");

    uploadBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(uploadBtn);

    Button downloadBtn = new Button("Download");

    LazyStreamSource streamSource = new LazyStreamSource() {
        private static final long serialVersionUID = 1L;

        @Override
        protected StreamSource buildStreamSource() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getStreamSourceSupportExtDrive(selectedResources);
        }

        @Override
        public String getFilename() {
            Collection<Resource> selectedResources = getSelectedResources();
            return StreamDownloadResourceUtil.getDownloadFileName(selectedResources);
        }
    };
    OnDemandFileDownloader downloaderExt = new OnDemandFileDownloader(streamSource);
    downloaderExt.extend(downloadBtn);

    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    downloadBtn.setDescription("Download");
    downloadBtn.setEnabled(AppContext.canRead(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    navButton.addButton(downloadBtn);

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

        @Override
        public void buttonClick(ClickEvent event) {
            Collection<Resource> selectedResources = getSelectedResources();
            if (CollectionUtils.isNotEmpty(selectedResources)) {
                MoveResourceWindow moveResourceWindow = new MoveResourceWindow(selectedResources);
                UI.getCurrent().addWindow(moveResourceWindow);
            } else {
                NotificationUtil.showWarningNotification("Please select at least one item to move");
            }
        }
    });
    moveToBtn.setIcon(FontAwesome.ARROWS);
    moveToBtn.addStyleName(UIConstants.THEME_BROWN_LINK);
    moveToBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));
    moveToBtn.setDescription("Move to");
    navButton.addButton(moveToBtn);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    Collection<Resource> selectedResources = getSelectedResources();
                    if (CollectionUtils.isEmpty(selectedResources)) {
                        NotificationUtil.showWarningNotification("Please select at least one item to delete");
                    } else {
                        deleteResourceAction();
                    }
                }
            });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.THEME_RED_LINK);
    deleteBtn.setDescription("Delete resource");
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.PUBLIC_DOCUMENT_ACCESS));

    navButton.addButton(deleteBtn);
    controllGroupBtn.addComponent(navButton);

    mainBodyLayout.addComponent(controllGroupBtn);

    resourcesContainer = new ResourcesContainer(baseFolder);

    mainBodyLayout.addComponent(resourcesContainer);
    this.addComponent(mainBodyLayout);
}

From source file:com.esofthead.mycollab.module.project.ui.components.ProjectListNoItemView.java

License:Open Source License

public ProjectListNoItemView() {
    MVerticalLayout layout = new MVerticalLayout();
    layout.addStyleName("case-noitem");
    layout.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Label image = new Label(viewIcon().getHtml(), ContentMode.HTML);
    image.setSizeUndefined();/*from   ww w . j ava  2s.  co m*/
    layout.with(image).withAlign(image, Alignment.TOP_CENTER);

    Label title = new Label(viewTitle());
    title.addStyleName("h2");
    title.setSizeUndefined();
    layout.with(title).withAlign(title, Alignment.TOP_CENTER);

    Label body = new Label(viewHint());
    body.setWidthUndefined();
    layout.addComponent(body);

    Button createBugBtn = new Button(actionMessage(), actionListener());
    createBugBtn.setEnabled(hasPermission());

    MHorizontalLayout links = new MHorizontalLayout();

    links.addComponent(createBugBtn);
    createBugBtn.addStyleName(UIConstants.THEME_GREEN_LINK);

    layout.addComponent(links);
    this.addComponent(layout);
    this.setComponentAlignment(layout, Alignment.TOP_CENTER);
}

From source file:com.esofthead.mycollab.module.project.ui.components.TimeLogEditWindow.java

License:Open Source License

private void initUI() {
    this.setWidth("900px");

    headerPanel = new MHorizontalLayout().withWidth("100%");
    content.addComponent(headerPanel);// w w  w.  j a va  2  s .c  o m
    constructSpentTimeEntryPanel();
    constructRemainTimeEntryPanel();

    this.tableItem = new DefaultPagedBeanTable<>(
            ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class), SimpleItemTimeLogging.class,
            Arrays.asList(TimeTableFieldDef.logUser, TimeTableFieldDef.logForDate, TimeTableFieldDef.logValue,
                    TimeTableFieldDef.billable,
                    new TableViewField(null, "id", UIConstants.TABLE_CONTROL_WIDTH)));

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

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging timeLoggingItem = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);

            return new ProjectUserLink(timeLoggingItem.getLoguser(), timeLoggingItem.getLogUserAvatarId(),
                    timeLoggingItem.getLogUserFullName());

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging monitorItem = TimeLogEditWindow.this.tableItem.getBeanByIndex(itemId);
            final Label l = new Label();
            l.setValue(AppContext.formatDate(monitorItem.getLogforday()));
            return l;
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging itemTimeLogging = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);
            final Label l = new Label();
            l.setValue(itemTimeLogging.getLogvalue() + "");
            return l;
        }
    });

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

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleItemTimeLogging monitorItem = tableItem.getBeanByIndex(itemId);
            FontIconLabel icon;
            if (monitorItem.getIsbillable()) {
                icon = new FontIconLabel(FontAwesome.CHECK);
            } else {
                icon = new FontIconLabel(FontAwesome.TIMES);
            }
            icon.setStyleName(UIConstants.BUTTON_ICON_ONLY);
            return icon;
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            final SimpleItemTimeLogging itemTimeLogging = TimeLogEditWindow.this.tableItem
                    .getBeanByIndex(itemId);
            final Button deleteBtn = new Button(null, new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    TimeLogEditWindow.this.itemTimeLoggingService.removeWithSession(itemTimeLogging.getId(),
                            AppContext.getUsername(), AppContext.getAccountId());
                    TimeLogEditWindow.this.loadTimeValue();
                }
            });
            deleteBtn.setIcon(FontAwesome.TRASH_O);
            deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
            itemTimeLogging.setExtraData(deleteBtn);

            deleteBtn.setEnabled(CurrentProjectVariables.isAdmin()
                    || AppContext.getUsername().equals(itemTimeLogging.getLoguser()));
            return deleteBtn;
        }
    });

    this.tableItem.setWidth("100%");
    content.addComponent(tableItem);
}

From source file:com.esofthead.mycollab.module.project.view.bug.BugDashboardViewImpl.java

License:Open Source License

private void initHeader() {
    final Label title = new ProjectViewHeader(ProjectTypeConstants.BUG,
            AppContext.getMessage(BugI18nEnum.VIEW_BUG_DASHBOARD_TITLE));
    header.with(title).withAlign(title, Alignment.MIDDLE_LEFT).expand(title);

    final Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_BUG),
            new Button.ClickListener() {
                @Override//from w w  w.j av a2 s.  c  o  m
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance().post(new BugEvent.GotoAdd(this, null));
                }
            });
    createBugBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
    createBugBtn.setIcon(FontAwesome.PLUS);
    final SplitButton controlsBtn = new SplitButton(createBugBtn);
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setWidthUndefined();

    final VerticalLayout btnControlsLayout = new VerticalLayout();
    final Button createComponentBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_COMPONENT),
            new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null));
                }
            });
    createComponentBtn.setStyleName("link");
    createComponentBtn
            .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
    btnControlsLayout.addComponent(createComponentBtn);

    final Button createVersionBtn = new Button(AppContext.getMessage(BugI18nEnum.BUTTON_NEW_VERSION),
            new Button.ClickListener() {
                @Override
                public void buttonClick(final ClickEvent event) {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null));
                }
            });
    createVersionBtn.setStyleName("link");
    createVersionBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS));
    btnControlsLayout.addComponent(createVersionBtn);

    controlsBtn.setContent(btnControlsLayout);
    header.addComponent(controlsBtn);
}