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, ContentMode contentMode) 

Source Link

Document

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

Usage

From source file:com.esofthead.mycollab.module.project.view.milestone.MilestoneListViewImpl.java

License:Open Source License

private void constructBody() {
    this.bodyContent = CustomLayoutExt.createLayout("milestoneView");

    bodyContent.setWidth("100%");
    bodyContent.setStyleName("milestone-view");

    final MHorizontalLayout closedHeaderLayout = new MHorizontalLayout();

    final Label closedHeader = new Label(FontAwesome.MINUS.getHtml() + " "
            + AppContext.getMessage(MilestoneI18nEnum.WIDGET_CLOSED_PHASE_TITLE), ContentMode.HTML);
    closedHeader.setSizeUndefined();/*  ww w.  j a v a 2 s  .  com*/
    closedHeaderLayout.addComponent(closedHeader);
    closedHeaderLayout.setComponentAlignment(closedHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(closedHeaderLayout, "closed-header");
    closeContainer = new CssLayout();
    closeContainer.setStyleName("milestone-col");
    closeContainer.setWidth("100%");
    bodyContent.addComponent(this.closeContainer, "closed-milestones");

    final MHorizontalLayout inProgressHeaderLayout = new MHorizontalLayout();
    final Label inProgressHeader = new Label(FontAwesome.SPINNER.getHtml() + " "
            + AppContext.getMessage(MilestoneI18nEnum.WIDGET_INPROGRESS_PHASE_TITLE), ContentMode.HTML);
    inProgressHeader.setSizeUndefined();
    inProgressHeaderLayout.addComponent(inProgressHeader);
    inProgressHeaderLayout.setComponentAlignment(inProgressHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(inProgressHeaderLayout, "in-progress-header");
    inProgressContainer = new CssLayout();
    inProgressContainer.setStyleName("milestone-col");
    inProgressContainer.setWidth("100%");
    bodyContent.addComponent(this.inProgressContainer, "in-progress-milestones");

    final MHorizontalLayout futureHeaderLayout = new MHorizontalLayout();
    final Label futureHeader = new Label(FontAwesome.CLOCK_O.getHtml() + " "
            + AppContext.getMessage(MilestoneI18nEnum.WIDGET_FUTURE_PHASE_TITLE), ContentMode.HTML);
    futureHeader.setSizeUndefined();
    futureHeaderLayout.addComponent(futureHeader);
    futureHeaderLayout.setComponentAlignment(futureHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(futureHeaderLayout, "future-header");
    futureContainer = new CssLayout();
    futureContainer.setStyleName("milestone-col");
    futureContainer.setWidth("100%");
    bodyContent.addComponent(this.futureContainer, "future-milestones");

    this.addComponent(bodyContent);
}

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

License:Open Source License

private void generateDisplayTable() {
    tableItem = new DefaultPagedBeanTable<>(AppContextUtil.getSpringBean(ProjectService.class),
            SimpleProject.class, ProjectTypeConstants.PROJECT, ProjectTableFieldDef.selected(),
            Arrays.asList(ProjectTableFieldDef.projectName(), ProjectTableFieldDef.lead(),
                    ProjectTableFieldDef.client(), ProjectTableFieldDef.startDate(),
                    ProjectTableFieldDef.homePage(), ProjectTableFieldDef.status()));

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

        @Override//  w w w.  jav  a  2 s.co  m
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleProject item = tableItem.getBeanByIndex(itemId);
            final CheckBoxDecor cb = new CheckBoxDecor("", item.isSelected());
            cb.setImmediate(true);
            cb.addValueChangeListener(new Property.ValueChangeListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    tableItem.fireSelectItemEvent(item);
                }
            });
            item.setExtraData(cb);
            return cb;
        }
    });

    tableItem.addGeneratedColumn(Project.Field.name.name(), new Table.ColumnGenerator() {
        @Override
        public Object generateCell(Table table, Object itemId, Object columnId) {
            SimpleProject project = tableItem.getBeanByIndex(itemId);
            LabelLink b = new LabelLink(project.getName(),
                    ProjectLinkBuilder.generateProjectFullLink(project.getId()));
            b.setDescription(ProjectTooltipGenerator.generateToolTipProject(AppContext.getUserLocale(),
                    AppContext.getDateFormat(), project, AppContext.getSiteUrl(),
                    AppContext.getUserTimeZone()));
            MHorizontalLayout layout = new MHorizontalLayout(ProjectAssetsUtil
                    .buildProjectLogo(project.getShortname(), project.getId(), project.getAvatarid(), 32), b)
                            .expand(b).alignAll(Alignment.MIDDLE_LEFT).withMargin(false).withFullHeight();
            return layout;
        }
    });

    tableItem.addGeneratedColumn(Project.Field.lead.name(), new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            SimpleProject project = tableItem.getBeanByIndex(itemId);
            return new Label(ProjectLinkBuilder.generateProjectMemberHtmlLink(project.getId(),
                    project.getLead(), project.getLeadFullName(), project.getLeadAvatarId(), true),
                    ContentMode.HTML);
        }
    });

    tableItem.addGeneratedColumn(Project.Field.accountid.name(), new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            SimpleProject project = tableItem.getBeanByIndex(itemId);
            if (project.getAccountid() != null) {
                LabelLink b = new LabelLink(project.getClientName(),
                        ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid()));
                b.setIconLink(CrmAssetsManager.getAsset(CrmTypeConstants.ACCOUNT));
                return b;
            } else {
                return new Label();
            }
        }
    });

    tableItem.addGeneratedColumn(Project.Field.planstartdate.name(), new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            SimpleProject project = tableItem.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(project.getPlanstartdate()));
        }
    });

    tableItem.addGeneratedColumn(Project.Field.planenddate.name(), new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            SimpleProject project = tableItem.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(project.getPlanenddate()));
        }
    });

    tableItem.addGeneratedColumn(Project.Field.createdtime.name(), new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            SimpleProject project = tableItem.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(project.getCreatedtime()));
        }
    });

    tableItem.addGeneratedColumn(Project.Field.homepage.name(), new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            SimpleProject project = tableItem.getBeanByIndex(itemId);
            if (StringUtils.isNotBlank(project.getHomepage())) {
                return new Label(
                        new A(project.getHomepage(), "_blank").appendText(project.getHomepage()).write(),
                        ContentMode.HTML);
            } else {
                return new Label();
            }
        }
    });

    tableItem.setWidth("100%");

    bodyLayout.addComponent(constructTableActionControls());
    bodyLayout.addComponent(tableItem);
}

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

License:Open Source License

@Override
public void displayTags(Tag tag) {
    removeAllComponents();//from  ww  w .  j  a v a 2  s  .  c o  m

    MHorizontalLayout header = new MHorizontalLayout().withStyleName("hdr-view").withWidth("100%");

    Label headerLbl = new Label(FontAwesome.TAGS.getHtml() + " Tags", ContentMode.HTML);
    headerLbl.setSizeUndefined();
    headerLbl.setStyleName("hdr-text");
    header.with(headerLbl);

    MHorizontalLayout contentWrapper = new MHorizontalLayout();

    MVerticalLayout rightSideBar = new MVerticalLayout().withSpacing(false).withWidth("450px");
    MHorizontalLayout panelHeader = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, true))
            .withHeight("34px").withWidth("100%");
    panelHeader.addStyleName("panel-header");
    Label lbl = new Label("Tag Cloud");
    panelHeader.with(lbl);

    TagCloudComp cloudComp = new TagCloudComp();
    cloudComp.displayTagItems();
    rightSideBar.with(panelHeader, cloudComp);

    contentWrapper.with(rightSideBar);
    with(header, contentWrapper);
}

From source file:com.esofthead.mycollab.module.project.view.task.components.ToggleTaskSummaryField.java

License:Open Source License

public ToggleTaskSummaryField(final SimpleTask task, int maxLength) {
    this.setWidth("100%");
    this.maxLength = maxLength;
    this.task = task;
    titleLinkLbl = new Label(buildTaskLink(), ContentMode.HTML);
    titleLinkLbl.setWidthUndefined();//from   w  w  w.  j  a  v  a2  s  . co  m
    titleLinkLbl.addStyleName(UIConstants.LABEL_WORD_WRAP);

    this.addComponent(titleLinkLbl);
    buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
    if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
        this.addStyleName("editable-field");

        Button instantEditBtn = new Button(null, new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                if (isRead) {
                    ToggleTaskSummaryField.this.removeComponent(titleLinkLbl);
                    ToggleTaskSummaryField.this.removeComponent(buttonControls);
                    final TextField editField = new TextField();
                    editField.setValue(task.getTaskname());
                    editField.setWidth("100%");
                    editField.focus();
                    ToggleTaskSummaryField.this.addComponent(editField);
                    ToggleTaskSummaryField.this.removeStyleName("editable-field");
                    editField.addValueChangeListener(new Property.ValueChangeListener() {
                        @Override
                        public void valueChange(Property.ValueChangeEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    editField.addBlurListener(new FieldEvents.BlurListener() {
                        @Override
                        public void blur(FieldEvents.BlurEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    isRead = !isRead;
                }
            }
        });
        instantEditBtn.setDescription("Edit task name");
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        instantEditBtn.setIcon(FontAwesome.EDIT);
        buttonControls.with(instantEditBtn);
        this.addComponent(buttonControls);
    }
}

From source file:com.esofthead.mycollab.module.project.view.task.GanttChartViewImpl.java

License:Open Source License

public GanttChartViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));

    MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withStyleName("hdr-view").withWidth("100%");
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    Label headerText = new Label(FontAwesome.BAR_CHART_O.getHtml() + " Gantt chart", ContentMode.HTML);
    headerText.setStyleName(UIConstants.HEADER_TEXT);

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

        @Override//from  w  w  w  .  j  a  v  a2  s. c  om
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskListEvent.GotoTaskListScreen(this, null));
        }
    });
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription(AppContext.getMessage(TaskGroupI18nEnum.ADVANCED_VIEW_TOOLTIP));

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

        @Override
        public void buttonClick(Button.ClickEvent event) {
            TaskSearchCriteria searchCriteria = new TaskSearchCriteria();
            searchCriteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId()));
            searchCriteria.setStatuses(
                    new SetSearchField<>(new String[] { OptionI18nEnum.StatusI18nEnum.Open.name() }));
            TaskFilterParameter taskFilter = new TaskFilterParameter(searchCriteria, "Task Search");
            taskFilter.setAdvanceSearch(true);
            EventBusFactory.getInstance().post(new TaskEvent.Search(this, taskFilter));
        }
    });
    simpleDisplayBtn.setIcon(FontAwesome.LIST_UL);
    simpleDisplayBtn.setDescription(AppContext.getMessage(TaskGroupI18nEnum.LIST_VIEW_TOOLTIP));

    Button chartDisplayBtn = new Button();
    chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O);

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(simpleDisplayBtn);
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(chartDisplayBtn);
    viewButtons.setDefaultButton(chartDisplayBtn);

    header.with(headerText, viewButtons).withAlign(headerText, Alignment.MIDDLE_LEFT).expand(headerText);

    taskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class);

    HorizontalLayout ganttLayout = constructGanttChart();

    MVerticalLayout wrapContent = new MVerticalLayout().withSpacing(false).withMargin(false)
            .withStyleName("gantt-view").with(createControls(), ganttLayout);
    this.with(header, wrapContent);
}

From source file:com.esofthead.mycollab.module.project.view.task.TaskSearchViewImpl.java

License:Open Source License

public TaskSearchViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));

    MVerticalLayout taskListLayout = new MVerticalLayout().withSpacing(false);
    with(taskListLayout);//from   w  w w . java2  s .  co m

    this.taskSearchPanel = new TaskSearchPanel();
    this.generateDisplayTable();

    final MHorizontalLayout header = new MHorizontalLayout().withStyleName(UIConstants.HEADER_VIEW)
            .withWidth("100%");

    headerText = new Label(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml(),
            ContentMode.HTML);
    headerText.setSizeUndefined();
    headerText.setStyleName(UIConstants.HEADER_TEXT);

    Button backBtn = new Button(AppContext.getMessage(TaskI18nEnum.BUTTON_BACK_TO_DASHBOARD),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    EventBusFactory.getInstance().post(new TaskListEvent.GotoTaskListScreen(this, null));

                }
            });
    backBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    backBtn.setIcon(FontAwesome.ARROW_LEFT);

    header.with(headerText, backBtn).withAlign(headerText, Alignment.MIDDLE_LEFT)
            .withAlign(backBtn, Alignment.MIDDLE_RIGHT).expand(headerText);

    taskListLayout.with(header, taskSearchPanel, tableItem);
}

From source file:com.esofthead.mycollab.module.project.view.time.TimeTrackingTableDisplay.java

License:Open Source License

public TimeTrackingTableDisplay(List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class), SimpleItemTimeLogging.class,
            displayColumns);//from w ww. j ava2  s.com

    this.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 timeItem = TimeTrackingTableDisplay.this.getBeanByIndex(itemId);

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

        }
    });

    this.addGeneratedColumn("summary", 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) {
            SimpleItemTimeLogging itemLogging = TimeTrackingTableDisplay.this.getBeanByIndex(itemId);

            try {
                VerticalLayout summaryWrapper = new VerticalLayout();

                String type = itemLogging.getType();

                if (type == null) {
                    return new Label(itemLogging.getNote(), ContentMode.HTML);
                } else {
                    Label timeTrackingLink = new Label(buildItemValue(itemLogging), ContentMode.HTML);
                    timeTrackingLink.addStyleName("link");
                    timeTrackingLink.addStyleName(UIConstants.WORD_WRAP);
                    timeTrackingLink.setWidth("100%");

                    if (ProjectTypeConstants.BUG.equals(type)) {
                        if (BugStatus.Verified.name().equals(itemLogging.getStatus())) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_COMPLETED);
                        } else if (itemLogging.getDueDate() != null
                                && (itemLogging.getDueDate().before(DateTimeUtils.getCurrentDateWithoutMS()))) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_OVERDUE);
                        }
                    } else if (type.equals(ProjectTypeConstants.TASK)) {
                        if (itemLogging.getPercentageComplete() != null
                                && 100d == itemLogging.getPercentageComplete()) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_COMPLETED);
                        } else {
                            if (OptionI18nEnum.StatusI18nEnum.Pending.name().equals(itemLogging.getStatus())) {
                                timeTrackingLink.addStyleName(UIConstants.LINK_PENDING);
                            } else if (itemLogging.getDueDate() != null && (itemLogging.getDueDate()
                                    .before(DateTimeUtils.getCurrentDateWithoutMS()))) {
                                timeTrackingLink.addStyleName(UIConstants.LINK_OVERDUE);
                            }
                        }
                    } else {
                        if (OptionI18nEnum.StatusI18nEnum.Closed.name().equals(itemLogging.getStatus())) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_COMPLETED);
                        } else if (itemLogging.getDueDate() != null
                                && (itemLogging.getDueDate().before(DateTimeUtils.getCurrentDateWithoutMS()))) {
                            timeTrackingLink.addStyleName(UIConstants.LINK_OVERDUE);
                        }
                    }
                    summaryWrapper.addComponent(timeTrackingLink);

                    if (StringUtils.isNotBlank(itemLogging.getNote())) {
                        summaryWrapper.addComponent(new Label(itemLogging.getNote(), ContentMode.HTML));
                    }

                    return summaryWrapper;
                }

            } catch (Exception e) {
                LOG.error("Error: " + BeanUtility.printBeanObj(itemLogging), e);
                return new Label("");
            }

        }
    }

    );

    this.

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

                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    final SimpleItemTimeLogging itemLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);

                    LabelLink b = new LabelLink(itemLogging.getProjectName(),
                            ProjectLinkBuilder.generateProjectFullLink(itemLogging.getProjectid()));
                    b.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.PROJECT));
                    return b;
                }
            }

    );

    this.

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

                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    final SimpleItemTimeLogging timeLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);
                    FontIconLabel icon;
                    if (timeLogging.getIsbillable()) {
                        icon = new FontIconLabel(FontAwesome.CHECK);
                    } else {
                        icon = new FontIconLabel(FontAwesome.TIMES);
                    }
                    return icon;
                }
            }

    );

    this.

            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 timeLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);
                    final Label l = new Label();
                    l.setValue(AppContext.formatDate(timeLogging.getLogforday()));
                    return l;
                }
            }

    );

    this.

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

                @Override
                public Object generateCell(Table source, Object itemId, Object columnId) {
                    final SimpleItemTimeLogging itemLogging = TimeTrackingTableDisplay.this
                            .getBeanByIndex(itemId);

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

                        @Override
                        public void buttonClick(ClickEvent event) {
                            fireTableEvent(
                                    new TableClickEvent(TimeTrackingTableDisplay.this, itemLogging, "edit"));

                        }
                    });
                    editBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
                    editBtn.setIcon(FontAwesome.EDIT);

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

                        @Override
                        public void buttonClick(ClickEvent event) {
                            fireTableEvent(
                                    new TableClickEvent(TimeTrackingTableDisplay.this, itemLogging, "delete"));

                        }
                    });
                    deleteBtn.setIcon(FontAwesome.TRASH_O);
                    deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
                    layout.with(editBtn, deleteBtn);
                    return layout;
                }

            }

    );

    this.

            setWidth("100%");
}

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

License:Open Source License

@Override
public void display() {
    projects = ApplicationContextUtil.getSpringBean(ProjectService.class)
            .getProjectsUserInvolved(AppContext.getUsername(), AppContext.getAccountId());
    if (CollectionUtils.isNotEmpty(projects)) {
        itemTimeLoggingService = ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class);

        final CssLayout headerWrapper = new CssLayout();
        headerWrapper.setWidth("100%");
        headerWrapper.setStyleName("projectfeed-hdr-wrapper");

        HorizontalLayout loggingPanel = new HorizontalLayout();

        HorizontalLayout controlBtns = new HorizontalLayout();
        controlBtns.setMargin(new MarginInfo(true, false, true, false));

        final Label layoutHeader = new Label(
                ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME).getHtml() + " Time Tracking",
                ContentMode.HTML);
        layoutHeader.addStyleName("h2");

        final MHorizontalLayout header = new MHorizontalLayout().withWidth("100%");
        header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader);

        final CssLayout contentWrapper = new CssLayout();
        contentWrapper.setWidth("100%");
        contentWrapper.addStyleName(UIConstants.CONTENT_WRAPPER);

        headerWrapper.addComponent(header);
        this.addComponent(headerWrapper);
        contentWrapper.addComponent(controlBtns);

        MHorizontalLayout controlsPanel = new MHorizontalLayout().withWidth("100%");

        contentWrapper.addComponent(controlsPanel);
        contentWrapper.addComponent(loggingPanel);
        this.addComponent(contentWrapper);

        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override/*from www .j a va  2s. c o m*/
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

        controlBtns.addComponent(backBtn);

        VerticalLayout selectionLayoutWrapper = new VerticalLayout();
        selectionLayoutWrapper.setWidth("100%");
        selectionLayoutWrapper.addStyleName("time-tracking-summary-search-panel");
        controlsPanel.addComponent(selectionLayoutWrapper);

        final GridLayout selectionLayout = new GridLayout(9, 2);
        selectionLayout.setSpacing(true);
        selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
        selectionLayout.setMargin(true);
        selectionLayoutWrapper.addComponent(selectionLayout);

        Label fromLb = new Label("From:");
        fromLb.setWidthUndefined();
        selectionLayout.addComponent(fromLb, 0, 0);

        this.fromDateField = new PopupDateFieldExt();
        this.fromDateField.setResolution(Resolution.DAY);
        this.fromDateField.setDateFormat(AppContext.getUserDateFormat());
        this.fromDateField.setWidth("100px");
        selectionLayout.addComponent(this.fromDateField, 1, 0);

        Label toLb = new Label("To:");
        toLb.setWidthUndefined();
        selectionLayout.addComponent(toLb, 2, 0);

        this.toDateField = new PopupDateFieldExt();
        this.toDateField.setResolution(Resolution.DAY);
        this.toDateField.setDateFormat(AppContext.getUserDateFormat());
        this.toDateField.setWidth("100px");
        selectionLayout.addComponent(this.toDateField, 3, 0);

        Label groupLb = new Label("Group:");
        groupLb.setWidthUndefined();
        selectionLayout.addComponent(groupLb, 0, 1);

        this.groupField = new ValueComboBox(false, GROUPBY_PROJECT, GROUPBY_DATE, GROUPBY_USER);
        this.groupField.setWidth("100px");
        selectionLayout.addComponent(this.groupField, 1, 1);

        Label sortLb = new Label("Sort:");
        sortLb.setWidthUndefined();
        selectionLayout.addComponent(sortLb, 2, 1);

        this.orderField = new ItemOrderComboBox();
        this.orderField.setWidth("100px");
        selectionLayout.addComponent(this.orderField, 3, 1);

        Label projectLb = new Label("Project:");
        projectLb.setWidthUndefined();
        selectionLayout.addComponent(projectLb, 4, 0);

        this.projectField = new UserInvolvedProjectsListSelect();
        initListSelectStyle(this.projectField);
        selectionLayout.addComponent(this.projectField, 5, 0, 5, 1);

        Label userLb = new Label("User:");
        userLb.setWidthUndefined();
        selectionLayout.addComponent(userLb, 6, 0);

        this.userField = new UserInvolvedProjectsMemberListSelect(getProjectIds());
        initListSelectStyle(this.userField);
        selectionLayout.addComponent(this.userField, 7, 0, 7, 1);

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

                    @Override
                    public void buttonClick(final ClickEvent event) {
                        fromDate = fromDateField.getValue();
                        toDate = toDateField.getValue();
                        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
                        searchTimeReporting();
                    }
                });
        queryBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

        selectionLayout.addComponent(queryBtn, 8, 0);

        loggingPanel.setWidth("100%");
        loggingPanel.setHeight("80px");
        loggingPanel.setSpacing(true);

        totalHoursLoggingLabel = new Label("Total Hours Logging: 0 Hrs", ContentMode.HTML);
        totalHoursLoggingLabel.addStyleName(UIConstants.LAYOUT_LOG);
        totalHoursLoggingLabel.addStyleName(UIConstants.TEXT_LOG_DATE_FULL);
        loggingPanel.addComponent(totalHoursLoggingLabel);
        loggingPanel.setExpandRatio(totalHoursLoggingLabel, 1.0f);
        loggingPanel.setComponentAlignment(totalHoursLoggingLabel, Alignment.MIDDLE_LEFT);

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

            @Override
            public void buttonClick(ClickEvent event) {
                exportButtonControl.setPopupVisible(true);

            }
        });
        exportButtonControl = new SplitButton(exportBtn);
        exportButtonControl.setWidthUndefined();
        exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK);
        exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);

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

        Button exportPdfBtn = new Button("Pdf");
        FileDownloader pdfDownloader = new FileDownloader(constructStreamResource(ReportExportType.PDF));
        pdfDownloader.extend(exportPdfBtn);
        exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O);
        exportPdfBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportPdfBtn);

        Button exportExcelBtn = new Button("Excel");
        FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL));
        excelDownloader.extend(exportExcelBtn);
        exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
        exportExcelBtn.setStyleName("link");
        popupButtonsControl.addComponent(exportExcelBtn);

        controlBtns.addComponent(exportButtonControl);
        controlBtns.setComponentAlignment(exportButtonControl, Alignment.TOP_RIGHT);
        controlBtns.setComponentAlignment(backBtn, Alignment.TOP_LEFT);
        controlBtns.setSizeFull();

        this.timeTrackingWrapper = new VerticalLayout();
        this.timeTrackingWrapper.setWidth("100%");
        contentWrapper.addComponent(this.timeTrackingWrapper);

        Calendar date = new GregorianCalendar();
        date.set(Calendar.DAY_OF_MONTH, 1);

        fromDate = date.getTime();
        date.add(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH));
        toDate = date.getTime();

        fromDateField.setValue(fromDate);
        toDateField.setValue(toDate);

        searchCriteria = new ItemTimeLoggingSearchCriteria();

        searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate));
    } else {
        final Button backBtn = new Button("Back to Workboard");
        backBtn.addClickListener(new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                EventBusFactory.getInstance()
                        .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null));

            }
        });

        backBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
        backBtn.setIcon(FontAwesome.ARROW_LEFT);

        VerticalLayout contentWrapper = new VerticalLayout();
        contentWrapper.setSpacing(true);

        Label infoLbl = new Label("You are not involved in any project yet to track time working");
        infoLbl.setWidthUndefined();
        contentWrapper.setMargin(true);
        contentWrapper.addComponent(infoLbl);
        contentWrapper.setComponentAlignment(infoLbl, Alignment.MIDDLE_CENTER);

        contentWrapper.addComponent(backBtn);
        contentWrapper.setComponentAlignment(backBtn, Alignment.MIDDLE_CENTER);
        this.addComponent(contentWrapper);
        this.setComponentAlignment(contentWrapper, Alignment.MIDDLE_CENTER);
    }
}

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

License:Open Source License

@Override
public Component generateRow(AbstractBeanPagedList host, ProjectGenericTask genericTask, int rowIndex) {
    MHorizontalLayout rowComp = new MHorizontalLayout().withStyleName("list-row").withFullWidth();
    rowComp.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    Div issueDiv = new Div();
    issueDiv.appendText(ProjectAssetsManager.getAsset(genericTask.getType()).getHtml());

    String status = "";
    if (genericTask.isBug()) {
        status = AppContext.getMessage(OptionI18nEnum.BugStatus.class, genericTask.getStatus());
    } else if (genericTask.isMilestone()) {
        status = AppContext.getMessage(OptionI18nEnum.MilestoneStatus.class, genericTask.getStatus());
    } else if (genericTask.isRisk()) {
        status = AppContext.getMessage(com.esofthead.mycollab.common.i18n.OptionI18nEnum.StatusI18nEnum.class,
                genericTask.getStatus());
    } else if (genericTask.isTask()) {
        status = AppContext.getMessage(com.esofthead.mycollab.common.i18n.OptionI18nEnum.StatusI18nEnum.class,
                genericTask.getStatus());
    }/*from   w ww  .java 2s . c  o  m*/
    issueDiv.appendChild(new Span().appendText(status).setCSSClass(UIConstants.FIELD_NOTE));

    String avatarLink = StorageFactory.getInstance().getAvatarPath(genericTask.getAssignUserAvatarId(), 16);
    Img img = new Img(genericTask.getAssignUserFullName(), avatarLink)
            .setTitle(genericTask.getAssignUserFullName());
    issueDiv.appendChild(img, DivLessFormatter.EMPTY_SPACE());

    A taskLink = new A().setId("tag" + TOOLTIP_ID);
    taskLink.setAttribute("onmouseover",
            TooltipHelper.projectHoverJsFunction(genericTask.getType(), genericTask.getTypeId() + ""));
    taskLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());
    if (ProjectTypeConstants.BUG.equals(genericTask.getType())
            || ProjectTypeConstants.TASK.equals(genericTask.getType())) {
        taskLink.appendText(String.format("[%s-%d] - %s", genericTask.getProjectShortName(),
                genericTask.getExtraTypeId(), genericTask.getName()));
        taskLink.setHref(ProjectLinkBuilder.generateProjectItemLink(genericTask.getProjectShortName(),
                genericTask.getProjectId(), genericTask.getType(), genericTask.getExtraTypeId() + ""));
    } else {
        taskLink.appendText(genericTask.getName());
        taskLink.setHref(ProjectLinkBuilder.generateProjectItemLink(genericTask.getProjectShortName(),
                genericTask.getProjectId(), genericTask.getType(), genericTask.getTypeId() + ""));
    }

    issueDiv.appendChild(taskLink);
    if (genericTask.isClosed()) {
        taskLink.setCSSClass("completed");
    } else if (genericTask.isOverdue()) {
        taskLink.setCSSClass("overdue");
        issueDiv.appendChild(
                new Span().appendText(" - Due in " + AppContext.formatDuration(genericTask.getDueDate()))
                        .setCSSClass(UIConstants.META_INFO));
    }

    MHorizontalLayout iconsLayout = new MHorizontalLayout().with(
            new ELabel(ProjectAssetsManager.getAsset(genericTask.getType()).getHtml(), ContentMode.HTML),
            new ELabel(img.write(), ContentMode.HTML));
    Label issueLbl = new Label(issueDiv.write(), ContentMode.HTML);
    rowComp.with(issueLbl);
    return rowComp;
}

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

License:Open Source License

@Override
public void doSearch() {
    this.totalCount = this.projectActivityStreamService
            .getTotalActivityStream(this.searchRequest.getSearchCriteria());
    this.totalPage = (this.totalCount - 1) / this.searchRequest.getNumberOfItems() + 1;
    if (this.searchRequest.getCurrentPage() > this.totalPage) {
        this.searchRequest.setCurrentPage(this.totalPage);
    }/*from w  w w .ja v  a2s .co  m*/

    if (totalPage > 1) {
        if (this.controlBarWrapper != null) {
            this.removeComponent(this.controlBarWrapper);
        }
        this.addComponent(this.createPageControls());
    } else {
        if (getComponentCount() == 2) {
            removeComponent(getComponent(1));
        }
    }

    final List<ProjectActivityStream> currentListData = this.projectActivityStreamService
            .getProjectActivityStreams(this.searchRequest);
    this.listContainer.removeAllComponents();
    Date currentDate = new GregorianCalendar(2100, 1, 1).getTime();

    CssLayout currentFeedBlock = new CssLayout();

    try {
        for (final ProjectActivityStream activityStream : currentListData) {
            if (ProjectTypeConstants.PAGE.equals(activityStream.getType())) {
                ProjectPageService pageService = ApplicationContextUtil.getSpringBean(ProjectPageService.class);
                Page page = pageService.getPage(activityStream.getTypeid(), AppContext.getUsername());
                if (page != null) {
                    activityStream.setNamefield(page.getSubject());
                }
            }

            final Date itemCreatedDate = activityStream.getCreatedtime();

            if (!DateUtils.isSameDay(currentDate, itemCreatedDate)) {
                currentFeedBlock = new CssLayout();
                currentFeedBlock.setStyleName("feed-block");
                feedBlocksPut(currentDate, itemCreatedDate, currentFeedBlock);
                currentDate = itemCreatedDate;
            }
            StringBuffer content = new StringBuffer();
            String itemType = AppContext
                    .getMessage(ProjectLocalizationTypeMap.getType(activityStream.getType()));
            String assigneeParam = buildAssigneeValue(activityStream);
            String itemParam = buildItemValue(activityStream);

            if (ActivityStreamConstants.ACTION_CREATE.equals(activityStream.getAction())) {
                content.append(
                        AppContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_CREATE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
            } else if (ActivityStreamConstants.ACTION_UPDATE.equals(activityStream.getAction())) {
                content.append(
                        AppContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_UPDATE_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
                if (activityStream.getAssoAuditLog() != null) {
                    content.append(
                            ProjectAuditLogStreamGenerator.generatorDetailChangeOfActivity(activityStream));
                }
            } else if (ActivityStreamConstants.ACTION_COMMENT.equals(activityStream.getAction())) {
                content.append(
                        AppContext.getMessage(ProjectCommonI18nEnum.FEED_USER_ACTIVITY_COMMENT_ACTION_TITLE,
                                assigneeParam, itemType, itemParam));
                if (activityStream.getAssoAuditLog() != null) {
                    content.append("<p><ul><li>\"").append(activityStream.getAssoAuditLog().getChangeset())
                            .append("\"</li></ul></p>");
                }

            }
            final Label actionLbl = new Label(content.toString(), ContentMode.HTML);
            final CssLayout streamWrapper = new CssLayout();
            streamWrapper.setWidth("100%");
            streamWrapper.addStyleName("stream-wrapper");
            streamWrapper.addComponent(actionLbl);
            currentFeedBlock.addComponent(streamWrapper);
        }
    } catch (final Exception e) {
        throw new MyCollabException(e);
    }
}