Example usage for com.vaadin.ui Label Label

List of usage examples for com.vaadin.ui Label Label

Introduction

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

Prototype

public Label(String text) 

Source Link

Document

Creates a new instance with text content mode and the given text.

Usage

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

License:Open Source License

public OpportunityTableDisplay(String viewId, TableViewField requiredColumn,
        List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(OpportunityService.class), SimpleOpportunity.class, viewId,
            requiredColumn, displayColumns);

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

        @Override/*from   w w  w.j  av a  2  s  .co  m*/
        public Object generateCell(final Table source, final Object itemId, Object columnId) {
            final SimpleOpportunity opportunity = OpportunityTableDisplay.this.getBeanByIndex(itemId);
            final CheckBoxDecor cb = new CheckBoxDecor("", opportunity.isSelected());
            cb.setImmediate(true);
            cb.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    OpportunityTableDisplay.this.fireSelectItemEvent(opportunity);
                    fireTableEvent(new TableClickEvent(OpportunityTableDisplay.this, opportunity, "selected"));
                }
            });

            opportunity.setExtraData(cb);
            return cb;
        }
    });

    this.addGeneratedColumn("opportunityname", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleOpportunity opportunity = OpportunityTableDisplay.this.getBeanByIndex(itemId);

            LabelLink b = new LabelLink(opportunity.getOpportunityname(),
                    CrmLinkBuilder.generateOpportunityPreviewLinkFull(opportunity.getId()));
            if ("Closed Won".equals(opportunity.getSalesstage())
                    || "Closed Lost".equals(opportunity.getSalesstage())) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else {
                if (opportunity.getExpectedcloseddate() != null
                        && (opportunity.getExpectedcloseddate().before(new GregorianCalendar().getTime()))) {
                    b.addStyleName(UIConstants.LINK_OVERDUE);
                }
            }
            b.setDescription(CrmTooltipGenerator.generateTooltipOpportunity(AppContext.getUserLocale(),
                    opportunity, AppContext.getSiteUrl(), AppContext.getTimezone()));

            return b;
        }
    });

    this.addGeneratedColumn("amount", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleOpportunity opportunity = OpportunityTableDisplay.this.getBeanByIndex(itemId);

            String amount = "";
            if (opportunity.getAmount() != null) {
                amount = opportunity.getAmount() + "";

                if (opportunity.getCurrency() != null) {
                    amount += " " + opportunity.getCurrency().getSymbol();
                }
            }

            return new Label(amount);
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleOpportunity opportunity = OpportunityTableDisplay.this.getBeanByIndex(itemId);
            return new UserLink(opportunity.getAssignuser(), opportunity.getAssignUserAvatarId(),
                    opportunity.getAssignUserFullName());

        }
    });

    this.addGeneratedColumn("accountName", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleOpportunity opportunity = OpportunityTableDisplay.this.getBeanByIndex(itemId);

            return new LabelLink(opportunity.getAccountName(),
                    CrmLinkBuilder.generateAccountPreviewLinkFull(opportunity.getAccountid()));
        }
    });

    this.addGeneratedColumn("campaignName", new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleOpportunity opportunity = OpportunityTableDisplay.this.getBeanByIndex(itemId);

            return new LabelLink(opportunity.getCampaignName(),
                    CrmLinkBuilder.generateCampaignPreviewLinkFull(opportunity.getCampaignid()));
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, Object itemId, Object columnId) {
            final SimpleOpportunity opportunity = OpportunityTableDisplay.this.getBeanByIndex(itemId);
            Label l = new Label();
            l.setValue(AppContext.formatDate(opportunity.getExpectedcloseddate()));
            return l;
        }
    });

    this.setWidth("100%");
}

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

License:Open Source License

public HorizontalLayout constructHeader() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.setSpacing(true);/*from w ww .j  a v a 2s  .co m*/
    layout.setMargin(true);

    final Image titleIcon = new Image(null, MyCollabResource.newResource("icons/24/project/file.png"));
    layout.addComponent(titleIcon);
    layout.setComponentAlignment(titleIcon, Alignment.MIDDLE_LEFT);

    final Label searchtitle = new Label("Files");
    searchtitle.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(searchtitle);
    layout.setComponentAlignment(searchtitle, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(searchtitle, 1.0f);
    return layout;
}

From source file:com.esofthead.mycollab.module.file.view.DropBoxOAuthWindow.java

License:Open Source License

public DropBoxOAuthWindow() {
    super();//  w w  w  . j a v  a2 s.  c om
    this.setWidth("420px");
    this.setResizable(false);
    this.center();
    this.setContent(new Label("Do not support this feature in this edition"));
}

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

License:Open Source License

protected ComponentContainer constructHeader(String headerText) {
    Label headerLbl = new Label(headerText);
    headerLbl.setSizeUndefined();/*from  w  w  w.  j  a v a  2 s.  co  m*/
    header = new HorizontalLayout();
    headerLbl.setStyleName("hdr-text");

    if (titleIcon != null)
        UiUtils.addComponent(header, titleIcon, Alignment.MIDDLE_LEFT);

    UiUtils.addComponent(header, headerLbl, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(headerLbl, 1.0f);

    header.setStyleName("hdr-view");
    header.setWidth("100%");
    header.setSpacing(true);
    header.setMargin(true);

    return header;
}

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

License:Open Source License

public GenericTaskTableDisplay(List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(ProjectGenericTaskService.class), ProjectGenericTask.class,
            displayColumns);//  w  ww  .  jav  a2 s  .  c  o  m

    addGeneratedColumn("name", 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) {
            HorizontalLayout layout = new HorizontalLayout();

            final ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId);

            if (task.getType() != null) {
                FontIconLabel icon = new FontIconLabel(ProjectAssetsManager.getAsset(task.getType()));
                layout.addComponent(icon);
                layout.setComponentAlignment(icon, Alignment.MIDDLE_CENTER);
            }
            final ButtonLink b = new ButtonLink(task.getName(), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    fireTableEvent(new TableClickEvent(GenericTaskTableDisplay.this, task, "name"));
                }
            });
            b.setWidth("100%");
            layout.addComponent(b);
            layout.setExpandRatio(b, 1.0f);
            layout.setWidth("100%");
            return layout;
        }
    });

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

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId);
            return new UserLink(task.getAssignUser(), task.getAssignUserAvatarId(),
                    task.getAssignUserFullName());
        }

    });

    addGeneratedColumn("dueDate", 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 ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(task.getDueDate()));
        }
    });
}

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

License:Open Source License

private void constructSpentTimeEntryPanel() {
    VerticalLayout spentTimePanel = new VerticalLayout();
    spentTimePanel.setSpacing(true);/*from   w w w  .  j a v  a  2s .  c o  m*/
    headerPanel.addComponent(spentTimePanel);

    final VerticalLayout totalLayout = new VerticalLayout();
    totalLayout.setMargin(true);
    totalLayout.addStyleName("boxTotal");
    totalLayout.setWidth("100%");
    spentTimePanel.addComponent(totalLayout);
    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_TOTAL_SPENT_HOURS));
    totalLayout.addComponent(lbTimeInstructTotal);
    this.totalSpentTimeLbl = new Label("_");
    this.totalSpentTimeLbl.addStyleName("numberTotal");
    totalLayout.addComponent(this.totalSpentTimeLbl);

    final MHorizontalLayout addLayout = new MHorizontalLayout();
    addLayout.setSizeUndefined();
    addLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    spentTimePanel.addComponent(addLayout);

    this.newTimeInputField = new NumericTextField();
    this.newTimeInputField.setWidth("80px");

    this.forDateField = new DateFieldExt();
    this.forDateField.setValue(new GregorianCalendar().getTime());

    this.isBillableField = new CheckBox(AppContext.getMessage(TimeTrackingI18nEnum.FORM_IS_BILLABLE), true);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            double d = 0;
            try {
                d = Double.parseDouble(newTimeInputField.getValue());
            } catch (NumberFormatException e) {
                NotificationUtil.showWarningNotification("You must enter a positive number value");
            }
            if (d > 0) {
                saveTimeInvest();
                loadTimeValue();
                newTimeInputField.setValue("0.0");
            }
        }

    });

    btnAdd.setEnabled(TimeLogEditWindow.this.isEnableAdd());
    btnAdd.setStyleName(UIConstants.THEME_GREEN_LINK);
    btnAdd.setIcon(FontAwesome.PLUS);
    addLayout.with(this.newTimeInputField, this.forDateField, this.isBillableField, btnAdd);
}

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

License:Open Source License

private void constructRemainTimeEntryPanel() {
    VerticalLayout remainTimePanel = new VerticalLayout();
    remainTimePanel.setSpacing(true);//from   w w w .  ja v  a  2s  .  com
    this.headerPanel.addComponent(remainTimePanel);

    final VerticalLayout updateLayout = new VerticalLayout();
    updateLayout.setMargin(true);
    updateLayout.addStyleName("boxTotal");
    updateLayout.setWidth("100%");
    remainTimePanel.addComponent(updateLayout);

    final Label lbTimeInstructTotal = new Label(
            AppContext.getMessage(TimeTrackingI18nEnum.OPT_REMAINING_WORK_HOURS));
    updateLayout.addComponent(lbTimeInstructTotal);
    this.remainTimeLbl = new Label("_");
    this.remainTimeLbl.addStyleName("numberTotal");
    updateLayout.addComponent(this.remainTimeLbl);

    final MHorizontalLayout addLayout = new MHorizontalLayout();
    addLayout.setSizeUndefined();
    remainTimePanel.addComponent(addLayout);

    this.remainTimeInputField = new NumericTextField();
    this.remainTimeInputField.setWidth("80px");
    addLayout.addComponent(this.remainTimeInputField);
    addLayout.setComponentAlignment(this.remainTimeInputField, Alignment.MIDDLE_LEFT);

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

        @Override
        public void buttonClick(final ClickEvent event) {

            try {
                double d = 0;
                try {
                    d = Double.parseDouble(remainTimeInputField.getValue());
                } catch (Exception e) {
                    NotificationUtil.showWarningNotification("You must enter a positive number value");
                }
                if (d >= 0) {
                    updateTimeRemain();
                    remainTimeLbl.setValue(remainTimeInputField.getValue());
                    remainTimeInputField.setValue("0.0");
                }
            } catch (final Exception e) {
                remainTimeInputField.setValue("0.0");
            }
        }

    });

    btnAdd.setEnabled(TimeLogEditWindow.this.isEnableAdd());
    btnAdd.setStyleName(UIConstants.THEME_GREEN_LINK);
    addLayout.addComponent(btnAdd);
    addLayout.setComponentAlignment(btnAdd, Alignment.MIDDLE_LEFT);
}

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

License:Open Source License

@Override
protected void displayGroupItems(List<SimpleItemTimeLogging> timeLoggingEntries) {
    if (timeLoggingEntries.size() > 0) {
        Label label = new Label(DATE_FORMAT.format(timeLoggingEntries.get(0).getLogforday()));
        label.addStyleName(UIConstants.TEXT_LOG_DATE);
        addComponent(label);/*from w ww. jav a  2  s  .c o m*/

        addComponent(new TimeLoggingBockLayout(visibleFields, tableClickListener, timeLoggingEntries));
    }
}

From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.PredecessorWindow.java

License:Open Source License

PredecessorWindow(final GanttTreeTable taskTreeTable, final GanttItemWrapper ganttItemWrapper) {
    super("Edit predecessors");
    this.setModal(true);
    this.setResizable(false);
    this.setWidth("650px");
    this.center();
    this.taskTreeTable = taskTreeTable;
    this.ganttItemWrapper = ganttItemWrapper;

    MVerticalLayout content = new MVerticalLayout();
    this.setContent(content);
    Label headerLbl = new Label(
            String.format("Row %d: %s", ganttItemWrapper.getGanttIndex(), ganttItemWrapper.getName()));
    headerLbl.addStyleName(ValoTheme.LABEL_H2);
    content.add(headerLbl);/* w  w w  . java  2  s  . c  o m*/

    CssLayout preWrapper = new CssLayout();
    content.with(preWrapper);

    MHorizontalLayout headerLayout = new MHorizontalLayout();
    headerLayout.addComponent(new ELabel("Row").withWidth(ROW_WDITH));
    headerLayout.addComponent(new ELabel("Task").withWidth(TASK_WIDTH));
    headerLayout.addComponent(new ELabel("Dependency").withWidth(PRE_TYPE_WIDTH));
    headerLayout.addComponent(new ELabel("Lag").withWidth(LAG_WIDTH));
    predecessorsLayout = new PredecessorsLayout();
    new Restrain(predecessorsLayout).setMaxHeight("600px");

    preWrapper.addComponent(headerLayout);
    preWrapper.addComponent(predecessorsLayout);

    MHorizontalLayout buttonControls = new MHorizontalLayout();
    content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    PredecessorWindow.this.close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);

    Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            List<TaskPredecessor> predecessors = predecessorsLayout.buildPredecessors();
            EventBusFactory.getInstance()
                    .post(new GanttEvent.ModifyPredecessors(ganttItemWrapper, predecessors));
            PredecessorWindow.this.close();
        }
    });
    saveBtn.addStyleName(UIConstants.BUTTON_ACTION);
    buttonControls.with(cancelBtn, saveBtn);
}

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

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final MHorizontalLayout layout = new MHorizontalLayout().withWidth("100%");

    final Label lbEmpty = new Label("");
    layout.with(lbEmpty).expand(lbEmpty);

    MHorizontalLayout buttonControls = new MHorizontalLayout();
    layout.addComponent(buttonControls);

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

        @Override/*from   w w w. j  av  a2 s .c o m*/
        public void buttonClick(ClickEvent event) {
            UI.getCurrent().addWindow(new BugListCustomizeWindow(BugListView.VIEW_DEF_ID, tableItem));

        }
    });
    customizeViewBtn.setIcon(FontAwesome.COG);
    customizeViewBtn.setDescription("Layout Options");
    customizeViewBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    buttonControls.addComponent(customizeViewBtn);

    PopupButton exportButtonControl = new PopupButton();
    exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
    exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);
    exportButtonControl.setDescription(AppContext.getMessage(FileI18nEnum.EXPORT_FILE));

    VerticalLayout popupButtonsControl = new VerticalLayout();
    exportButtonControl.setContent(popupButtonsControl);

    Button exportPdfBtn = new Button(AppContext.getMessage(FileI18nEnum.PDF));

    StreamWrapperFileDownloader fileDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() {

        @Override
        public StreamResource getStreamResource() {
            String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                    && CurrentProjectVariables.getProject().getName() != null)
                            ? CurrentProjectVariables.getProject().getName()
                            : "");
            BugSearchCriteria searchCriteria = new BugSearchCriteria();
            searchCriteria.setProjectId(
                    new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId()));

            return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                    new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.PDF,
                    ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class),
                    "export.pdf");
        }

    });
    fileDownloader.extend(exportPdfBtn);
    exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
    exportPdfBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportPdfBtn);

    Button exportExcelBtn = new Button(AppContext.getMessage(FileI18nEnum.EXCEL));
    StreamWrapperFileDownloader excelDownloader = new StreamWrapperFileDownloader(new StreamResourceFactory() {

        @Override
        public StreamResource getStreamResource() {
            String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                    && CurrentProjectVariables.getProject().getName() != null)
                            ? CurrentProjectVariables.getProject().getName()
                            : "");
            BugSearchCriteria searchCriteria = new BugSearchCriteria();
            searchCriteria.setProjectId(
                    new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProject().getId()));

            return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                    new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.EXCEL,
                    ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria, SimpleBug.class),
                    "export.xlsx");
        }
    });
    excelDownloader.extend(exportExcelBtn);
    exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
    exportExcelBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportExcelBtn);

    Button exportCsvBtn = new Button(AppContext.getMessage(FileI18nEnum.CSV));

    StreamWrapperFileDownloader csvFileDownloader = new StreamWrapperFileDownloader(
            new StreamResourceFactory() {

                @Override
                public StreamResource getStreamResource() {
                    String title = "Bugs of Project " + ((CurrentProjectVariables.getProject() != null
                            && CurrentProjectVariables.getProject().getName() != null)
                                    ? CurrentProjectVariables.getProject().getName()
                                    : "");
                    BugSearchCriteria searchCriteria = new BugSearchCriteria();
                    searchCriteria.setProjectId(new NumberSearchField(SearchField.AND,
                            CurrentProjectVariables.getProject().getId()));

                    return new StreamResource(new SimpleGridExportItemsStreamResource.AllItems<>(title,
                            new RpParameterBuilder(tableItem.getDisplayColumns()), ReportExportType.CSV,
                            ApplicationContextUtil.getSpringBean(BugService.class), searchCriteria,
                            SimpleBug.class), "export.csv");
                }
            });
    csvFileDownloader.extend(exportCsvBtn);

    exportCsvBtn.setIcon(FontAwesome.FILE_TEXT_O);
    exportCsvBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportCsvBtn);

    buttonControls.addComponent(exportButtonControl);
    return layout;
}