Example usage for com.vaadin.ui Button setCaption

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

Introduction

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

Prototype

@Override
    public void setCaption(String caption) 

Source Link

Usage

From source file:com.esofthead.mycollab.module.project.view.user.ProjectInfoComponent.java

License:Open Source License

public ProjectInfoComponent(final SimpleProject project) {
    this.withMargin(true).withStyleName("project-info").withFullWidth();
    Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(),
            project.getAvatarid(), 64);/* www . j  a  va2s.  c  om*/
    this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT);
    ELabel headerLbl = ELabel.h2(project.getName());
    headerLbl.setDescription(ProjectTooltipGenerator.generateToolTipProject(AppContext.getUserLocale(),
            AppContext.getDateFormat(), project, AppContext.getSiteUrl(), AppContext.getUserTimeZone()));
    headerLbl.addStyleName(UIConstants.TEXT_ELLIPSIS);
    MVerticalLayout headerLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true));

    MHorizontalLayout footer = new MHorizontalLayout();
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    footer.addStyleName(UIConstants.META_INFO);
    footer.addStyleName(UIConstants.FLEX_DISPLAY);

    ELabel createdTimeLbl = new ELabel(
            FontAwesome.CLOCK_O.getHtml() + " " + AppContext.formatPrettyTime(project.getCreatedtime()),
            ContentMode.HTML).withDescription(AppContext.getMessage(GenericI18Enum.FORM_CREATED_TIME))
                    .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(createdTimeLbl);

    billableHoursLbl = new ELabel(
            FontAwesome.MONEY.getHtml() + " " + NumberUtils.roundDouble(2, project.getTotalBillableHours()),
            ContentMode.HTML).withDescription(AppContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS))
                    .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(billableHoursLbl);

    nonBillableHoursLbl = new ELabel(FontAwesome.GIFT.getHtml() + " " + project.getTotalNonBillableHours(),
            ContentMode.HTML)
                    .withDescription(AppContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS))
                    .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(nonBillableHoursLbl);

    if (project.getLead() != null) {
        Div leadAvatar = new DivLessFormatter()
                .appendChild(
                        new Img("", StorageFactory.getInstance().getAvatarPath(project.getLeadAvatarId(), 16)),
                        DivLessFormatter.EMPTY_SPACE(),
                        new A(ProjectLinkBuilder.generateProjectMemberFullLink(project.getId(),
                                project.getLead()))
                                        .appendText(StringUtils.trim(project.getLeadFullName(), 30, true)))
                .setTitle(project.getLeadFullName());
        ELabel leadLbl = new ELabel("Lead: " + leadAvatar.write(), ContentMode.HTML).withWidthUndefined();
        footer.addComponents(leadLbl);
    }
    if (project.getHomepage() != null) {
        ELabel homepageLbl = new ELabel(FontAwesome.WECHAT.getHtml() + " "
                + new A(project.getHomepage()).appendText(project.getHomepage()).setTarget("_blank").write(),
                ContentMode.HTML).withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
        homepageLbl.setDescription(AppContext.getMessage(ProjectI18nEnum.FORM_HOME_PAGE));
    }

    if (project.getNumActiveMembers() > 0) {
        ELabel activeMembersLbl = new ELabel(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers(),
                ContentMode.HTML).withDescription("Active members").withStyleName(ValoTheme.LABEL_SMALL)
                        .withWidthUndefined();
        footer.addComponents(activeMembersLbl);
    }

    if (project.getAccountid() != null && !SiteConfiguration.isCommunityEdition()) {
        Div clientDiv = new Div();
        if (project.getClientAvatarId() == null) {
            clientDiv.appendText(FontAwesome.INSTITUTION.getHtml() + " ");
        } else {
            Img clientImg = new Img("", StorageFactory.getInstance()
                    .getEntityLogoPath(AppContext.getAccountId(), project.getClientAvatarId(), 16));
            clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE());
        }
        clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid()))
                .appendText(project.getClientName()));
        ELabel accountBtn = new ELabel(clientDiv.write(), ContentMode.HTML)
                .withStyleName(UIConstants.BUTTON_BLOCK).withWidthUndefined();
        footer.addComponents(accountBtn);
    }

    if (!SiteConfiguration.isCommunityEdition()) {
        Button tagBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null));
                    }
                });
        tagBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        tagBtn.addStyleName(UIConstants.BUTTON_ACTION);
        tagBtn.setDescription("Tag management");
        tagBtn.setIcon(FontAwesome.TAGS);
        footer.addComponents(tagBtn);

        Button favoriteBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null));
                    }
                });
        favoriteBtn.setCaptionAsHtml(true);
        favoriteBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        favoriteBtn.addStyleName(UIConstants.BUTTON_ACTION);
        favoriteBtn.setIcon(FontAwesome.STAR);
        favoriteBtn.setDescription("Your favorite list");
        footer.addComponents(favoriteBtn);

        Button eventBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this));
                    }
                });
        eventBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        eventBtn.addStyleName(UIConstants.BUTTON_ACTION);
        eventBtn.setIcon(FontAwesome.CALENDAR);
        eventBtn.setDescription("Calendar");
        footer.addComponents(eventBtn);

        Button ganttChartBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null));
                    }
                });
        ganttChartBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        ganttChartBtn.addStyleName(UIConstants.BUTTON_ACTION);
        ganttChartBtn.setIcon(FontAwesome.BAR_CHART_O);
        ganttChartBtn.setDescription("Gantt chart");
        footer.addComponents(ganttChartBtn);
    }

    headerLayout.with(headerLbl, footer);

    MHorizontalLayout topPanel = new MHorizontalLayout().withMargin(false);
    this.with(headerLayout, topPanel).expand(headerLayout).withAlign(topPanel, Alignment.TOP_RIGHT);

    if (project.isProjectArchived()) {
        Button activeProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class);
                        project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Open.name());
                        projectService.updateSelectiveWithSession(project, AppContext.getUsername());

                        PageActionChain chain = new PageActionChain(
                                new ProjectScreenData.Goto(CurrentProjectVariables.getProjectId()));
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, chain));

                    }
                });
        activeProjectBtn.setStyleName(UIConstants.BUTTON_ACTION);
        topPanel.with(activeProjectBtn).withAlign(activeProjectBtn, Alignment.MIDDLE_RIGHT);
    } else {
        SearchTextField searchField = new SearchTextField() {
            public void doSearch(String value) {
                ProjectView prjView = UIUtils.getRoot(this, ProjectView.class);
                if (prjView != null) {
                    prjView.displaySearchResult(value);
                }
            }

            @Override
            public void emptySearch() {

            }
        };

        final PopupButton controlsBtn = new PopupButton();
        controlsBtn.addStyleName(UIConstants.BOX);
        controlsBtn.setIcon(FontAwesome.ELLIPSIS_H);

        OptionPopupContent popupButtonsControl = new OptionPopupContent();

        Button createPhaseBtn = new Button(AppContext.getMessage(MilestoneI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new MilestoneEvent.GotoAdd(ProjectInfoComponent.this, null));
                    }
                });
        createPhaseBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
        createPhaseBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.MILESTONE));
        popupButtonsControl.addOption(createPhaseBtn);

        Button createTaskBtn = new Button(AppContext.getMessage(TaskI18nEnum.NEW), new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                controlsBtn.setPopupVisible(false);
                EventBusFactory.getInstance().post(new TaskEvent.GotoAdd(ProjectInfoComponent.this, null));
            }
        });
        createTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
        createTaskBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK));
        popupButtonsControl.addOption(createTaskBtn);

        Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.NEW), new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                controlsBtn.setPopupVisible(false);
                EventBusFactory.getInstance().post(new BugEvent.GotoAdd(this, null));
            }
        });
        createBugBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
        createBugBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG));
        popupButtonsControl.addOption(createBugBtn);

        Button createComponentBtn = new Button(AppContext.getMessage(ComponentI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null));
                    }
                });
        createComponentBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
        createComponentBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_COMPONENT));
        popupButtonsControl.addOption(createComponentBtn);

        Button createVersionBtn = new Button(AppContext.getMessage(VersionI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null));
                    }
                });
        createVersionBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS));
        createVersionBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_VERSION));
        popupButtonsControl.addOption(createVersionBtn);

        if (!SiteConfiguration.isCommunityEdition()) {
            Button createRiskBtn = new Button(AppContext.getMessage(RiskI18nEnum.NEW),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            controlsBtn.setPopupVisible(false);
                            EventBusFactory.getInstance().post(new RiskEvent.GotoAdd(this, null));
                        }
                    });
            createRiskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS));
            createRiskBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.RISK));
            popupButtonsControl.addOption(createRiskBtn);
        }

        popupButtonsControl.addSeparator();
        Button inviteMemberBtn = new Button(AppContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectMemberEvent.GotoInviteMembers(this, null));
                    }
                });
        inviteMemberBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
        inviteMemberBtn.setIcon(FontAwesome.SEND);
        popupButtonsControl.addOption(inviteMemberBtn);

        Button settingBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null));
                    }
                });
        settingBtn.setIcon(FontAwesome.COG);
        popupButtonsControl.addOption(settingBtn);

        popupButtonsControl.addSeparator();

        final Button markProjectTemplateBtn = new Button();
        markProjectTemplateBtn.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
                project.setIstemplate(isTemplate);
                ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class);
                prjService.updateWithSession(project, AppContext.getUsername());
                if (project.getIstemplate()) {
                    markProjectTemplateBtn
                            .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
                } else {
                    markProjectTemplateBtn
                            .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
                }
            }
        });
        markProjectTemplateBtn.setIcon(FontAwesome.STICKY_NOTE);
        Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
        if (isTemplate) {
            markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
        } else {
            markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
        }
        markProjectTemplateBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT));
        popupButtonsControl.addOption(markProjectTemplateBtn);

        Button editProjectBtn = new Button(AppContext.getMessage(ProjectI18nEnum.EDIT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project));
                    }
                });
        editProjectBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT));
        editProjectBtn.setIcon(FontAwesome.EDIT);
        popupButtonsControl.addOption(editProjectBtn);

        Button archiveProjectBtn = new Button(
                AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                AppContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE,
                                        AppContext.getSiteName()),
                                AppContext.getMessage(
                                        ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_ARCHIVE_MESSAGE),
                                AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                                AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                    private static final long serialVersionUID = 1L;

                                    @Override
                                    public void onClose(ConfirmDialog dialog) {
                                        if (dialog.isConfirmed()) {
                                            ProjectService projectService = AppContextUtil
                                                    .getSpringBean(ProjectService.class);
                                            project.setProjectstatus(
                                                    OptionI18nEnum.StatusI18nEnum.Archived.name());
                                            projectService.updateSelectiveWithSession(project,
                                                    AppContext.getUsername());

                                            PageActionChain chain = new PageActionChain(
                                                    new ProjectScreenData.Goto(
                                                            CurrentProjectVariables.getProjectId()));
                                            EventBusFactory.getInstance()
                                                    .post(new ProjectEvent.GotoMyProject(this, chain));
                                        }
                                    }
                                });
                    }
                });
        archiveProjectBtn
                .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
        archiveProjectBtn.setIcon(FontAwesome.ARCHIVE);
        popupButtonsControl.addOption(archiveProjectBtn);

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            popupButtonsControl.addSeparator();
            Button deleteProjectBtn = new Button(
                    AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            controlsBtn.setPopupVisible(false);
                            ConfirmDialogExt.show(UI.getCurrent(),
                                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                            AppContext.getSiteName()),
                                    AppContext.getMessage(
                                            ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_DELETE_MESSAGE),
                                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                                    AppContext.getMessage(GenericI18Enum.BUTTON_NO),
                                    new ConfirmDialog.Listener() {
                                        private static final long serialVersionUID = 1L;

                                        @Override
                                        public void onClose(ConfirmDialog dialog) {
                                            if (dialog.isConfirmed()) {
                                                ProjectService projectService = AppContextUtil
                                                        .getSpringBean(ProjectService.class);
                                                projectService.removeWithSession(
                                                        CurrentProjectVariables.getProject(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                EventBusFactory.getInstance()
                                                        .post(new ShellEvent.GotoProjectModule(this, null));
                                            }
                                        }
                                    });
                        }
                    });
            deleteProjectBtn
                    .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
            deleteProjectBtn.setIcon(FontAwesome.TRASH_O);
            popupButtonsControl.addDangerOption(deleteProjectBtn);
        }

        controlsBtn.setContent(popupButtonsControl);
        controlsBtn.setWidthUndefined();

        topPanel.with(searchField, controlsBtn).withAlign(searchField, Alignment.TOP_RIGHT)
                .withAlign(controlsBtn, Alignment.TOP_RIGHT);
    }
}

From source file:com.etest.view.notification.NotificationMainUI.java

Table populateNoficationTable() {
    notificationTable.removeAllItems();/* ww  w  .  java 2  s  .  c om*/
    int i = 0;
    for (EtestNotification en : ns.getAllNotificationByUser(
            CommonUtilities.convertStringToInt(VaadinSession.getCurrent().getAttribute("userId").toString()))) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button read = new Button();
        read.setWidthUndefined();
        read.setCaption((en.getStatus() == 0) ? "unread" : "read");
        read.setData(en.getNotificationId());
        read.setIcon(FontAwesome.VIDEO_CAMERA);
        read.addStyleName(ValoTheme.BUTTON_LINK);
        read.addStyleName(ValoTheme.BUTTON_TINY);
        read.addStyleName(ValoTheme.BUTTON_QUIET);
        read.addStyleName("button-container");
        read.addClickListener(buttonClickListener);
        v.addComponent(read);
        v.setComponentAlignment(read, Alignment.MIDDLE_LEFT);

        message.setContentMode(ContentMode.HTML);

        String[] split = en.getNotice().split(" ");
        int cellCaseId;
        if (split[0].equals("CellCaseID")) {
            message.setCaption(en.getRemarks() + en.getNotice());
            cellCaseId = CommonUtilities.convertStringToInt(split[1].replace("#", ""));
        } else {
            cellCaseId = cis.getCellItemById(CommonUtilities.convertStringToInt(split[1].replace("#", "")))
                    .getCellCaseId();
            message.setCaption(en.getRemarks() + en.getNotice() + " from CellCaseID #" + cellCaseId);
        }

        Button approve = new Button("status");
        approve.setSizeFull();
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        approve.addStyleName("button-container");
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        if (ccs.getCellCaseById(cellCaseId).getApprovalStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        notificationTable.addItem(new Object[] { message.getCaption().toString(),
                ss.getUsernameById(en.getSenderId()), en.getNoteDate(), v }, i);
        i++;
    }
    notificationTable.setPageLength(0);
    notificationTable.setHeight("100%");

    return notificationTable;
}

From source file:com.etest.view.notification.ViewCaseNotificationWindow.java

VerticalLayout buildForms() {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("700px");
    v.setMargin(true);/*from  ww  w  .j a  v  a  2  s.co  m*/
    v.setSpacing(true);

    Label cellCase = new Label();
    cellCase.setValue("<b>Case</b>: " + ccs.getCellCaseById(getCellCaseId()).getCaseTopic());
    cellCase.setContentMode(ContentMode.HTML);
    v.addComponent(cellCase);

    Label cellItem = new Label();
    cellItem.setContentMode(ContentMode.HTML);

    Button approvalBtn = new Button();
    approvalBtn.setCaption("Approve CASE");
    approvalBtn.setWidthUndefined();
    approvalBtn.addStyleName(ValoTheme.BUTTON_TINY);
    approvalBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approvalBtn.addClickListener(buttonClickListener);
    if (ccs.getCellCaseById(getCellCaseId()).getApprovalStatus() == 0) {
        approvalBtn.setVisible(true);
    } else {
        approvalBtn.setVisible(false);
    }
    v.addComponent(approvalBtn);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setWidth("100%");

    approvalItemBtn.setVisible(false);
    approvalItemBtn.setWidthUndefined();
    approvalItemBtn.addStyleName(ValoTheme.BUTTON_TINY);
    approvalItemBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);

    if (getCellItemId() != 0) {
        approvalBtn.setCaption("Approve ITEM");
        CellItem ci = cis.getCellItemById(getCellItemId());
        keyList = k.getAllItemKey(getCellItemId());
        keyIndexSize = keyList.size();

        if (keyList.isEmpty()) {
            ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem());
            return null;
        }

        stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>");
        cellItem.setValue("<b>STEM</b>: " + getStem());
        OptionGroup options = new OptionGroup();
        options.addItems(cis.getCellItemById(getCellItemId()).getOptionA(),
                cis.getCellItemById(getCellItemId()).getOptionB(),
                cis.getCellItemById(getCellItemId()).getOptionC(),
                cis.getCellItemById(getCellItemId()).getOptionD());
        h1.addComponent(options);
        h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER);

        if (cis.getCellItemById(getCellItemId()).getCellItemStatus() == 0) {
            approvalItemBtn.setVisible(true);
        } else {
            approvalItemBtn.setVisible(false);
        }
        approvalItemBtn.addClickListener(buttonClickListener);
        approvalItemBtn.setVisible(true);
    }
    v.addComponent(approvalBtn);
    v.addComponent(cellItem);
    v.addComponent(h1);
    v.addComponent(approvalItemBtn);

    Label separator = new Label("<HR>");
    separator.setContentMode(ContentMode.HTML);
    v.addComponent(separator);

    return v;
}

From source file:com.etest.view.systemadministration.SemestralTeamUI.java

void populateDataTable() {
    table.removeAllItems();/*from w w w . j  a va2s  . c o m*/
    int i = 0;
    for (TeamTeach tt : tts.getAllSemestralTeamTeach()) {
        HorizontalLayout hlayout = new HorizontalLayout();
        hlayout.setWidth("100%");

        Button membersBtn = new Button();
        membersBtn.setWidth("100%");
        membersBtn.setData(tt.getTeamTeachId());
        if (tts.countTeamMembers(tt.getTeamTeachId()) < 2) {
            membersBtn.setCaption("add");
            membersBtn.setIcon(FontAwesome.USER);
        } else {
            membersBtn.setCaption("view");
            membersBtn.setIcon(FontAwesome.USERS);
        }

        Button removeTLBtn = new Button("del");
        removeTLBtn.setWidth("100%");
        removeTLBtn.setIcon(FontAwesome.TRASH_O);
        removeTLBtn.setData(tt.getTeamTeachId());

        hlayout.addComponent(membersBtn);
        hlayout.addComponent(removeTLBtn);

        table.addItem(new Object[] { tt.getSchoolYear(),
                CommonVariableMap.getNormCourseOffering(tt.getNormCourseOffering()),
                CommonVariableMap.getYearLevel(tt.getYearLevel()), tt.getSubject(), tt.getTeamLeader(),
                hlayout }, i);
        i++;

        membersBtn.addStyleName(ValoTheme.BUTTON_LINK);
        membersBtn.addStyleName(ValoTheme.BUTTON_TINY);
        membersBtn.addClickListener(modifyBtnListener);

        removeTLBtn.addStyleName(ValoTheme.BUTTON_LINK);
        removeTLBtn.addStyleName(ValoTheme.BUTTON_TINY);
        removeTLBtn.addClickListener(modifyBtnListener);
    }
    table.setPageLength(table.size());
}

From source file:com.etest.view.tq.itemanalysis.TQItemAnalysisUI.java

public Table populateDataTable() {
    removeAllItems();/*from  w  w w  .j ava  2  s.  c om*/
    int i = 0;
    for (TQCoverage t : tq.getAllTQCoverage()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button analyze = new Button();
        analyze.setWidthUndefined();
        analyze.setData(t.getTqCoverageId());
        analyze.setCaption((t.getAnalyzed() == 0) ? "Unanalyze" : "Analyzed");
        analyze.setIcon(FontAwesome.BULLSEYE);
        analyze.addStyleName(ValoTheme.BUTTON_LINK);
        analyze.addStyleName(ValoTheme.BUTTON_TINY);
        analyze.addStyleName(ValoTheme.BUTTON_QUIET);
        analyze.addStyleName("button-container");
        analyze.setEnabled(t.getAnalyzed() == 0);
        analyze.addClickListener(buttonClickListener);
        v.addComponent(analyze);
        v.setComponentAlignment(analyze, Alignment.MIDDLE_LEFT);

        Button view = new Button("View");
        view.setWidthUndefined();
        view.setData(t.getTqCoverageId());
        view.setIcon(FontAwesome.VIDEO_CAMERA);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addStyleName("button-container");
        view.setVisible((t.getAnalyzed() != 0));
        view.addClickListener(buttonClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        addItem(new Object[] { t.getExamTitle(), cs.getCurriculumById(t.getCurriculumId()).getSubject(),
                t.getDateCreated(), t.getTotalHoursCoverage(), t.getTotalItems(), v }, i);
        i++;
    }
    setPageLength(size());

    return this;
}

From source file:com.fatminds.vaadin.cmis.components.CmisList.java

License:Apache License

public void addAssociationButtonColumn(final String headerText, final String buttonTextAdd,
        final String buttonTextRemove, final String dialogTextConfirmAdd, final String dialogTextConfirmRemove,
        final CmisAssociationContainer assocContainer, final CmisObject associationSource) {
    this.addGeneratedColumn(headerText, new Table.ColumnGenerator() {
        public Component generateCell(Table source, final Object itemId, final Object columnId) {
            CmisItem item = (CmisItem) getItem(itemId);
            // Find out if this item is already in the association
            boolean isAssociated = assocContainer.containsId(itemId);
            // the Link -component:
            final Button itemsButton = new Button(isAssociated ? buttonTextRemove : buttonTextAdd);
            itemsButton.setData(item);/*from ww w  . j  av a  2 s . c  o m*/
            itemsButton.addListener(new Button.ClickListener() {

                public void buttonClick(ClickEvent event) {
                    final CmisItem item = (CmisItem) event.getButton().getData();
                    setSelectedItem(item);
                    boolean exists = assocContainer.containsId(itemId);
                    if (assocContainer.containsId(itemId)) {
                        assocContainer.removeItem(itemId);
                        itemsButton.setCaption(buttonTextAdd);
                    } else {
                        assocContainer.addItem(item);
                        itemsButton.setCaption(buttonTextRemove);
                    }
                    /**
                     * Preferred impl needs an app-level window to display its confirmation dialog; replace with your favorite flavor 
                     * (we use an adaptation of navigator7)
                     * 
                     *                       ConfirmDialog.show(CatalogManagerApplication.getCurrentNavigableAppLevelWindow(), 
                     "Please Confirm", 
                     (exists ? dialogTextConfirmRemove : dialogTextConfirmAdd),
                       "Yes", 
                       "No", 
                       new ConfirmDialog.Listener() {
                            
                           public void onClose(ConfirmDialog dialog) {
                               if (dialog.isConfirmed()) {
                                   // Confirmed to continue
                                  if (assocContainer.containsId(itemId)) {
                                     assocContainer.removeItem(itemId);
                                     itemsButton.setCaption(buttonTextAdd);
                                  }
                                  else {
                                      assocContainer.addItem(item);
                                      itemsButton.setCaption(buttonTextRemove);
                                  }
                               } 
                           }
                       });
                    **/
                }

            });

            return itemsButton;
        }
    });
}

From source file:com.foc.vaadin.gui.layouts.validationLayout.FVValidationLayout.java

License:Apache License

private Button newButton(String iconName) {
    Button button = new Button("");

    if (validationSettings.getDiscardLink() != null && !validationSettings.getDiscardLink().isEmpty()) {
        button.setCaption(validationSettings.getDiscardLink());
    } else {//from ww  w .ja va  2 s.com
        button.setIcon(FVIconFactory.getInstance().getFVIcon_Big(iconName));
    }
    if (!Globals.isValo())
        button.setStyleName(BaseTheme.BUTTON_LINK);
    return button;
}

From source file:com.foo01.ui.ReservationDetailView.java

@Override
protected final void onBecomingVisible() {
    getNavigationBar().setCaption("Detail Rezervace");

    //buttony pod navbarem
    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setStyleName("buttonToolBarLayout");
    buttonsLayout.setWidth("100%");

    Button deleteButton = new Button();
    deleteButton.setCaption("SMAZAT");
    deleteButton.setWidth(null);/*from   w  w  w.ja  v a2s.  c  om*/
    buttonsLayout.addComponent(deleteButton);

    Label plug = new Label();
    buttonsLayout.addComponent(plug);

    Button saveButton = new Button();
    saveButton.setCaption("ULOIT");
    saveButton.setWidth(null);
    buttonsLayout.addComponent(saveButton);
    buttonsLayout.setExpandRatio(plug, 1.0f);
    List<Source> sourcesList = MockSource.mockSources();

    //combobox na zdroje a jmeno uzivatele
    HorizontalLayout sourceAndNameLayout = new HorizontalLayout();
    sourceAndNameLayout.setWidth("100%");
    sourceAndNameLayout.setStyleName("sourceAndNameLayout");

    NativeSelect select = new NativeSelect();
    select.setNullSelectionAllowed(false);
    System.out.println(Page.getCurrent().getBrowserWindowWidth());
    String width = Page.getCurrent().getBrowserWindowWidth() / 2.5 + "px";
    select.setWidth(width);
    select.addItems(sourcesList);
    for (Source s : sourcesList) {
        if (reservation.getSource().equals(s)) {
            select.select(s);
            break;
        }
    }
    sourceAndNameLayout.addComponent(select);

    Label plug2 = new Label();
    sourceAndNameLayout.addComponent(plug2);

    Label name = new Label(reservation.getUser());
    name.setWidth(null);
    sourceAndNameLayout.addComponent(name);
    sourceAndNameLayout.setExpandRatio(plug2, 1.0f);

    //datepickery
    DatePicker dateFrom = new DatePicker();
    dateFrom.setStyleName("datePickerDetailView");
    dateFrom.setValue(reservation.getBeginning());
    dateFrom.setUseNative(true);
    dateFrom.setResolution(Resolution.TIME);
    dateFrom.setWidth("100%");

    DatePicker dateTo = new DatePicker();
    dateTo.setStyleName("datePickerDetailView");
    dateTo.setValue(reservation.getEnding());
    dateTo.setUseNative(true);
    dateTo.setResolution(Resolution.TIME);
    dateTo.setWidth("100%");

    //layout pro slider a popisky
    HorizontalLayout sliderLayout = new HorizontalLayout();
    sliderLayout.setStyleName("sliderLayout");
    sliderLayout.setWidth("100%");
    sliderLayout.setSpacing(true);

    Label sliderCaption = new Label("Po?et: ");
    sliderCaption.addStyleName("sliderCaption");
    sliderCaption.setWidth(null);
    sliderLayout.addComponent(sliderCaption);

    final Label horvalue = new Label();
    horvalue.setWidth("45px");
    horvalue.setStyleName("value");
    sliderLayout.addComponent(horvalue);

    final Slider horslider = new Slider(1, 10);
    horslider.setOrientation(SliderOrientation.HORIZONTAL);
    horslider.setValue(Double.valueOf(1));
    horslider.getState();
    horslider.getValue();
    horslider.setImmediate(true);
    horslider.setWidth("100%");
    sliderLayout.addComponent(horslider);
    sliderLayout.setExpandRatio(horslider, 1.0f);

    horvalue.setValue(String.valueOf(horslider.getValue().intValue()));

    horslider.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            int value = horslider.getValue().intValue();

            horvalue.setValue(String.valueOf(value));
        }
    });

    //switch schvaleno
    HorizontalLayout switchLayout = new HorizontalLayout();
    switchLayout.setStyleName("switchLayout");
    switchLayout.addComponent(new Label("Schvleno:"));
    switchLayout.setSpacing(true);
    Switch checkbox = new Switch(null, true);
    switchLayout.addComponent(checkbox);

    //popis rezervace
    TextArea description = new TextArea();
    description.setStyleName("descriptionDetailView");

    description.setWidth("100%");
    description.setImmediate(false);
    description.setCaption("Popis:");
    description.setValue(reservation.getDescription());
    //description.setRequired(true);
    description.setRequiredError("Popis mus bt zadn!");
    description.setNullRepresentation("");
    description.setReadOnly(true);
    //description.setRows(0);

    final VerticalLayout content = new VerticalLayout();
    content.setMargin(true);
    content.setSpacing(true);
    content.setStyleName(width);
    content.addComponent(buttonsLayout);
    content.addComponent(sourceAndNameLayout);
    content.addComponent(dateFrom);
    content.addComponent(dateTo);

    content.addComponent(sliderLayout);
    content.addComponent(switchLayout);
    content.addComponent(description);

    setContent(content);
}

From source file:com.haulmont.cuba.web.exception.NoUserSessionHandler.java

License:Apache License

protected void showNoUserSessionDialog(App app) {
    Messages messages = AppBeans.get(Messages.NAME);

    Window dialog = new NoUserSessionExceptionDialog();
    dialog.setStyleName("c-nousersession-dialog");
    dialog.setCaption(messages.getMainMessage("dialogs.Information", locale));
    dialog.setClosable(false);/*from www. java2  s . co  m*/
    dialog.setResizable(false);
    dialog.setModal(true);

    AppUI ui = app.getAppUI();

    if (ui.isTestMode()) {
        dialog.setCubaId("optionDialog");
        dialog.setId(ui.getTestIdManager().getTestId("optionDialog"));
    }

    Label messageLab = new CubaLabel();
    messageLab.setWidthUndefined();
    messageLab.setValue(messages.getMainMessage("noUserSession.message", locale));

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setWidthUndefined();
    layout.setStyleName("c-nousersession-dialog-layout");
    layout.setSpacing(true);
    dialog.setContent(layout);

    Button reloginBtn = new Button();
    if (ui.isTestMode()) {
        reloginBtn.setCubaId("reloginBtn");
        reloginBtn.setId(ui.getTestIdManager().getTestId("reloginBtn"));
    }
    reloginBtn.addStyleName(WebButton.ICON_STYLE);
    reloginBtn.addStyleName("c-primary-action");
    reloginBtn.addClickListener(event -> relogin());
    reloginBtn.setCaption(messages.getMainMessage(Type.OK.getMsgKey()));

    String iconName = AppBeans.get(Icons.class).get(Type.OK.getIconKey());
    reloginBtn.setIcon(WebComponentsHelper.getIcon(iconName));

    ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);
    setClickShortcut(reloginBtn, clientConfig.getCommitShortcut());

    reloginBtn.focus();

    layout.addComponent(messageLab);
    layout.addComponent(reloginBtn);

    layout.setComponentAlignment(reloginBtn, Alignment.BOTTOM_RIGHT);

    ui.addWindow(dialog);

    dialog.center();
}

From source file:com.haulmont.cuba.web.gui.components.WebPickerField.java

License:Apache License

@Override
public void addAction(Action action, int index) {
    checkNotNullArgument(action, "action must be non null");

    int oldIndex = findActionById(actions, action.getId());
    if (oldIndex >= 0) {
        removeAction(actions.get(oldIndex));
        if (index > oldIndex) {
            index--;/* w w w  . ja va 2  s . co m*/
        }
    }

    actions.add(index, action);
    actionHandler.addAction(action, index);

    PickerButton pButton = new PickerButton();
    pButton.setAction(action);
    // no captions for picker buttons
    Button vButton = (Button) pButton.getComponent();
    vButton.setCaption("");

    component.addButton(vButton, index);

    // apply Editable after action owner is set
    if (action instanceof StandardAction) {
        ((StandardAction) action).setEditable(isEditable());
    }

    if (StringUtils.isNotEmpty(getDebugId())) {
        pButton.setDebugId(
                AppUI.getCurrent().getTestIdManager().getTestId(getDebugId() + "_" + action.getId()));
    }

    actionsPermissions.apply(action);
}