Example usage for com.vaadin.ui Alignment MIDDLE_LEFT

List of usage examples for com.vaadin.ui Alignment MIDDLE_LEFT

Introduction

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

Prototype

Alignment MIDDLE_LEFT

To view the source code for com.vaadin.ui Alignment MIDDLE_LEFT.

Click Source Link

Usage

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

License:Open Source License

public TaskKanbanBoardViewImpl() {
    this.setSizeFull();
    this.withSpacing(true).withMargin(new MarginInfo(false, true, true, true));
    searchPanel = new TaskSearchPanel();
    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    searchPanel.addHeaderRight(groupWrapLayout);

    toggleShowColumnsBtn = new MButton("", clickEvent -> {
        displayHiddenColumns = !displayHiddenColumns;
        reload();/*w  ww  . j a  v  a 2 s  . c o m*/
        toggleShowButton();
    }).withStyleName(WebThemes.BUTTON_LINK);
    groupWrapLayout.addComponent(toggleShowColumnsBtn);
    toggleShowButton();

    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS)) {
        MButton addNewColumnBtn = new MButton(UserUIContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN),
                clickEvent -> UI.getCurrent()
                        .addWindow(new AddNewColumnWindow(this, ProjectTypeConstants.TASK, "status")))
                                .withIcon(FontAwesome.PLUS).withStyleName(WebThemes.BUTTON_ACTION);
        groupWrapLayout.addComponent(addNewColumnBtn);
    }

    MButton deleteColumnBtn = new MButton(UserUIContext.getMessage(TaskI18nEnum.ACTION_DELETE_COLUMNS),
            clickEvent -> UI.getCurrent().addWindow(new DeleteColumnWindow(this, ProjectTypeConstants.TASK)))
                    .withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_DANGER);
    deleteColumnBtn.setVisible(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));

    MButton advanceDisplayBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_LIST),
            clickEvent -> EventBusFactory.getInstance().post(new TicketEvent.GotoDashboard(this, null)))
                    .withIcon(FontAwesome.NAVICON).withWidth("100px");

    MButton kanbanBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_KANBAN))
            .withIcon(FontAwesome.TH).withWidth("100px");

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.withDefaultButton(kanbanBtn);
    groupWrapLayout.addComponent(viewButtons);

    kanbanLayout = new DDHorizontalLayout();
    kanbanLayout.setHeight("100%");
    kanbanLayout.addStyleName("kanban-layout");
    kanbanLayout.setSpacing(true);
    kanbanLayout.setMargin(new MarginInfo(true, false, true, false));
    kanbanLayout.setComponentHorizontalDropRatio(0.3f);
    kanbanLayout.setDragMode(LayoutDragMode.CLONE_OTHER);

    // Enable dropping components
    kanbanLayout.setDropHandler(new DropHandler() {
        @Override
        public void drop(DragAndDropEvent event) {
            LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();

            DDHorizontalLayout.HorizontalLayoutTargetDetails details = (DDHorizontalLayout.HorizontalLayoutTargetDetails) event
                    .getTargetDetails();
            Component dragComponent = transferable.getComponent();
            if (dragComponent instanceof KanbanBlock) {
                KanbanBlock kanbanItem = (KanbanBlock) dragComponent;
                int newIndex = details.getOverIndex();
                if (details.getDropLocation() == HorizontalDropLocation.RIGHT) {
                    kanbanLayout.addComponent(kanbanItem);
                } else if (newIndex == -1) {
                    kanbanLayout.addComponent(kanbanItem, 0);
                } else {
                    kanbanLayout.addComponent(kanbanItem, newIndex);
                }

                //Update options index for this project
                List<Map<String, Integer>> indexMap = new ArrayList<>();
                for (int i = 0; i < kanbanLayout.getComponentCount(); i++) {
                    KanbanBlock blockItem = (KanbanBlock) kanbanLayout.getComponent(i);
                    Map<String, Integer> map = new HashMap<>(2);
                    map.put("id", blockItem.optionVal.getId());
                    map.put("index", i);
                    indexMap.add(map);
                }
                if (indexMap.size() > 0) {
                    optionValService.massUpdateOptionIndexes(indexMap, MyCollabUI.getAccountId());
                }
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return new Not(VerticalLocationIs.MIDDLE);
        }
    });

    this.with(searchPanel, kanbanLayout).expand(kanbanLayout);
}

From source file:com.mycollab.module.project.view.ticket.TicketDashboardViewImpl.java

License:Open Source License

public TicketDashboardViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));
    ticketSearchPanel = new TicketSearchPanel();

    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    groupWrapLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.ACTION_SORT)));
    final ComboBox sortCombo = new ValueComboBox(false,
            UserUIContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING),
            UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING));
    sortCombo.addValueChangeListener(valueChangeEvent -> {
        String sortValue = (String) sortCombo.getValue();
        if (UserUIContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) {
            sortDirection = SearchCriteria.ASC;
        } else {/*from  w  w w  .  j  a  va  2s. c om*/
            sortDirection = SearchCriteria.DESC;
        }
        queryAndDisplayTickets();
    });
    sortDirection = SearchCriteria.DESC;
    groupWrapLayout.addComponent(sortCombo);

    groupWrapLayout.addComponent(new ELabel(UserUIContext.getMessage(GenericI18Enum.OPT_GROUP)));
    final ComboBox groupCombo = new ValueComboBox(false, UserUIContext.getMessage(GenericI18Enum.FORM_DUE_DATE),
            UserUIContext.getMessage(GenericI18Enum.FORM_START_DATE),
            UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME),
            UserUIContext.getMessage(GenericI18Enum.OPT_PLAIN),
            UserUIContext.getMessage(GenericI18Enum.OPT_USER),
            UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupByState = UserUIContext.getMessage(MilestoneI18nEnum.SINGLE);
    groupCombo.setValue(UserUIContext.getMessage(MilestoneI18nEnum.SINGLE));
    groupCombo.addValueChangeListener(valueChangeEvent -> {
        groupByState = (String) groupCombo.getValue();
        queryAndDisplayTickets();
    });

    groupWrapLayout.addComponent(groupCombo);

    ticketSearchPanel.addHeaderRight(groupWrapLayout);

    MButton printBtn = new MButton("", clickEvent -> UI.getCurrent()
            .addWindow(new TicketCustomizeReportOutputWindow(new LazyValueInjector() {
                @Override
                protected Object doEval() {
                    return baseCriteria;
                }
            }))).withIcon(FontAwesome.PRINT).withStyleName(WebThemes.BUTTON_OPTION)
                    .withDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    groupWrapLayout.addComponent(printBtn);

    MButton newTicketBtn = new MButton(UserUIContext.getMessage(TicketI18nEnum.NEW), clickEvent -> {
        UI.getCurrent().addWindow(AppContextUtil.getSpringBean(TicketComponentFactory.class)
                .createNewTicketWindow(null, CurrentProjectVariables.getProjectId(), null, false));
    }).withIcon(FontAwesome.PLUS).withStyleName(WebThemes.BUTTON_ACTION)
            .withVisible(CurrentProjectVariables.canWriteTicket());
    groupWrapLayout.addComponent(newTicketBtn);

    MButton advanceDisplayBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_LIST))
            .withIcon(FontAwesome.NAVICON).withWidth("100px");

    MButton kanbanBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_KANBAN),
            clickEvent -> displayKanbanView()).withWidth("100px").withIcon(FontAwesome.TH);

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.withDefaultButton(advanceDisplayBtn);
    groupWrapLayout.addComponent(viewButtons);

    MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth();
    wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false));
    rightColumn = new MVerticalLayout().withWidth("370px")
            .withMargin(new MarginInfo(true, false, false, false));
    mainLayout.with(wrapBody, rightColumn).expand(wrapBody);
    this.with(ticketSearchPanel, mainLayout);
}

From source file:com.mycollab.module.project.view.ticket.TicketSearchPanel.java

License:Open Source License

@Override
protected ComponentContainer buildSearchTitle() {
    if (canSwitchToAdvanceLayout) {
        savedFilterComboBox = new TicketSavedFilterComboBox();
        savedFilterComboBox.addQuerySelectListener(new SavedFilterComboBox.QuerySelectListener() {
            @Override/*from   w ww.jav  a  2 s .c o  m*/
            public void querySelect(SavedFilterComboBox.QuerySelectEvent querySelectEvent) {
                List<SearchFieldInfo> fieldInfos = querySelectEvent.getSearchFieldInfos();
                ProjectTicketSearchCriteria criteria = SearchFieldInfo
                        .buildSearchCriteria(ProjectTicketSearchCriteria.class, fieldInfos);
                criteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
                EventBusFactory.getInstance()
                        .post(new TicketEvent.SearchRequest(TicketSearchPanel.this, criteria));
                EventBusFactory.getInstance().post(new ShellEvent.AddQueryParam(this, fieldInfos));
            }
        });
        ELabel taskIcon = ELabel.h2(ProjectAssetsManager.getAsset(ProjectTypeConstants.TICKET).getHtml())
                .withWidthUndefined();
        return new MHorizontalLayout(taskIcon, savedFilterComboBox).expand(savedFilterComboBox)
                .alignAll(Alignment.MIDDLE_LEFT);
    } else {
        return null;
    }
}

From source file:com.mycollab.module.project.view.ticket.UnresolvedTicketByPriorityWidget.java

License:Open Source License

private void displayPlainMode() {
    bodyContent.removeAllComponents();/*from ww  w . jav a2  s  .  c  o  m*/
    TicketPriorityClickListener listener = new TicketPriorityClickListener();
    this.setTitle(UserUIContext.getMessage(TaskI18nEnum.WIDGET_UNRESOLVED_BY_PRIORITY_TITLE) + " (" + totalCount
            + ")");

    if (!groupItems.isEmpty()) {
        for (Priority priority : OptionI18nEnum.priorities) {
            boolean isFound = false;
            for (GroupItem item : groupItems) {
                if (priority.name().equals(item.getGroupid())) {
                    isFound = true;
                    MHorizontalLayout priorityLayout = new MHorizontalLayout().withFullWidth();
                    priorityLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
                    MButton priorityLink = new ButtonI18nComp(priority.name(), priority, listener)
                            .withIcon(ProjectAssetsManager.getPriority(priority.name()))
                            .withStyleName(WebThemes.BUTTON_LINK, "priority-" + priority.name().toLowerCase())
                            .withWidth("110px");

                    priorityLayout.addComponent(priorityLink);
                    ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount,
                            totalCount - item.getValue().intValue(), false);
                    indicator.setWidth("100%");
                    priorityLayout.with(indicator).expand(indicator);

                    bodyContent.addComponent(priorityLayout);
                }
            }

            if (!isFound) {
                MHorizontalLayout priorityLayout = new MHorizontalLayout().withFullWidth();
                priorityLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
                MButton priorityLink = new ButtonI18nComp(priority.name(), priority, listener)
                        .withIcon(ProjectAssetsManager.getPriority(priority.name()))
                        .withStyleName(WebThemes.BUTTON_LINK, "priority-" + priority.name().toLowerCase())
                        .withWidth("110px");
                priorityLayout.addComponent(priorityLink);
                ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount, false);
                indicator.setWidth("100%");
                priorityLayout.with(indicator).expand(indicator);
                this.bodyContent.addComponent(priorityLayout);
            }
        }
    }
}

From source file:com.mycollab.module.project.view.ticket.UnresolvedTicketsByAssigneeWidget.java

License:Open Source License

private void displayPlainMode() {
    bodyContent.removeAllComponents();//  w ww  .  ja v a  2 s . c  o m
    int totalAssignTicketCounts = 0;
    if (CollectionUtils.isNotEmpty(groupItems)) {
        for (GroupItem item : groupItems) {
            MHorizontalLayout assigneeLayout = new MHorizontalLayout().withFullWidth();
            assigneeLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

            String assignUser = item.getGroupid();
            String assignUserFullName = item.getGroupid() == null ? "" : item.getGroupname();

            if (StringUtils.isBlank(assignUserFullName)) {
                assignUserFullName = StringUtils.extractNameFromEmail(item.getGroupid());
            }

            TicketAssigneeLink ticketAssigneeLink = new TicketAssigneeLink(assignUser, item.getExtraValue(),
                    assignUserFullName);
            assigneeLayout.addComponent(new MCssLayout(ticketAssigneeLink).withWidth("110px"));
            ProgressBarIndicator indicator = new ProgressBarIndicator(totalCountItems,
                    totalCountItems - item.getValue().intValue(), false);
            indicator.setWidth("100%");
            assigneeLayout.with(indicator).expand(indicator);
            bodyContent.addComponent(assigneeLayout);
            totalAssignTicketCounts += item.getValue().intValue();
        }
    }
    int totalUnassignTicketsCount = totalCountItems - totalAssignTicketCounts;
    if (totalUnassignTicketsCount > 0) {
        MButton unassignLink = new MButton("No assignee").withStyleName(WebThemes.BUTTON_LINK)
                .withIcon(UserAvatarControlFactory.createAvatarResource(null, 16)).withListener(clickEvent -> {
                    ProjectTicketSearchCriteria criteria = BeanUtility.deepClone(searchCriteria);
                    criteria.setUnAssignee(new SearchField());
                    EventBusFactory.getInstance().post(
                            new TicketEvent.SearchRequest(UnresolvedTicketsByAssigneeWidget.this, criteria));
                });
        MHorizontalLayout assigneeLayout = new MHorizontalLayout().withFullWidth();
        assigneeLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
        assigneeLayout.addComponent(new MCssLayout(unassignLink).withWidth("110px"));
        ProgressBarIndicator indicator = new ProgressBarIndicator(totalCountItems,
                totalCountItems - totalUnassignTicketsCount, false);
        indicator.setWidth("100%");
        assigneeLayout.with(indicator).expand(indicator);
        bodyContent.addComponent(assigneeLayout);
    }
}

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

License:Open Source License

public MyProjectListComponent() {
    withSpacing(false).withMargin(new MarginInfo(true, false, true, false));
    this.addStyleName("myprojectlist");

    MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, true))
            .withStyleName(WebThemes.PANEL_HEADER);
    titleLbl = new Label(UserUIContext.getMessage(ProjectCommonI18nEnum.WIDGET_ACTIVE_PROJECTS_TITLE, 0));

    final MButton sortBtn = new MButton("").withIcon(FontAwesome.SORT_ALPHA_ASC)
            .withStyleName(WebThemes.BUTTON_ICON_ONLY);
    sortBtn.addClickListener(clickEvent -> {
        isSortAsc = !isSortAsc;/*from w w  w. java  2 s . c  om*/
        if (searchCriteria != null) {
            if (isSortAsc) {
                sortBtn.setIcon(FontAwesome.SORT_ALPHA_ASC);
                searchCriteria.setOrderFields(
                        Collections.singletonList(new SearchCriteria.OrderField("name", SearchCriteria.ASC)));
            } else {
                sortBtn.setIcon(FontAwesome.SORT_ALPHA_DESC);
                searchCriteria.setOrderFields(
                        Collections.singletonList(new SearchCriteria.OrderField("name", SearchCriteria.DESC)));
            }
            displayResults();
        }
    });

    final SearchTextField searchTextField = new SearchTextField() {
        @Override
        public void doSearch(String value) {
            searchCriteria = getAllProjectsSearchCriteria();
            searchCriteria.setProjectName(StringSearchField.and(value));
            displayResults();
        }

        @Override
        public void emptySearch() {
            searchCriteria = getAllProjectsSearchCriteria();
            searchCriteria.setProjectName(null);
            displayResults();
        }
    };
    searchTextField.addStyleName(ValoTheme.TEXTFIELD_SMALL);

    final PopupButton projectsPopup = new PopupButton("");
    projectsPopup.setIcon(FontAwesome.CARET_SQUARE_O_DOWN);
    projectsPopup.addStyleName(WebThemes.BUTTON_ICON_ONLY);

    OptionPopupContent filterBtnLayout = new OptionPopupContent();

    ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class);
    int allProjectCount = projectService.getTotalCount(getAllProjectsSearchCriteria());
    Button allProjectsBtn = new Button(
            UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ALL_PROJECTS, allProjectCount),
            clickEvent -> {
                displayAllProjects();
                projectsPopup.setPopupVisible(false);
            });
    filterBtnLayout.addOption(allProjectsBtn);

    int activeProjectsCount = projectService.getTotalCount(getActiveProjectsSearchCriteria());
    Button activeProjectsBtn = new Button(
            UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECTS, activeProjectsCount),
            clickEvent -> {
                displayActiveProjects();
                projectsPopup.setPopupVisible(false);
            });
    filterBtnLayout.addOption(activeProjectsBtn);

    int archiveProjectsCount = projectService.getTotalCount(getArchivedProjectsSearchCriteria());
    Button archiveProjectsBtn = new Button(
            UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECTS, archiveProjectsCount),
            clickEvent -> {
                displayArchiveProjects();
                projectsPopup.setPopupVisible(false);
            });
    filterBtnLayout.addOption(archiveProjectsBtn);
    projectsPopup.setContent(filterBtnLayout);

    header.with(titleLbl, sortBtn, searchTextField, projectsPopup).expand(titleLbl)
            .alignAll(Alignment.MIDDLE_LEFT);

    this.projectList = new ProjectPagedList();
    this.with(header, projectList);
}

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

License:Open Source License

public ProjectInfoComponent(SimpleProject project) {
    this.withMargin(false).withFullWidth();
    Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(),
            project.getAvatarid(), 64);//from   www.ja  v a 2 s.  c  o m
    this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT);

    ProjectBreadcrumb breadCrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class);
    breadCrumb.setProject(project);
    MVerticalLayout headerLayout = new MVerticalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, true));

    MHorizontalLayout footer = new MHorizontalLayout().withStyleName(UIConstants.META_INFO,
            WebThemes.FLEX_DISPLAY);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel createdTimeLbl = ELabel
            .html(FontAwesome.CLOCK_O.getHtml() + " "
                    + UserUIContext.formatPrettyTime(project.getCreatedtime()))
            .withDescription(UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME))
            .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(createdTimeLbl);

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

    nonBillableHoursLbl = ELabel.html(FontAwesome.GIFT.getHtml() + " " + project.getTotalNonBillableHours())
            .withDescription(UserUIContext.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.getAvatarPath(project.getLeadAvatarId(), 16))
                                .setCSSClass(UIConstants.CIRCLE_BOX),
                        DivLessFormatter.EMPTY_SPACE(),
                        new A(ProjectLinkBuilder.generateProjectMemberFullLink(project.getId(),
                                project.getLead()))
                                        .appendText(StringUtils.trim(project.getLeadFullName(), 30, true)))
                .setTitle(project.getLeadFullName());
        ELabel leadLbl = ELabel
                .html(UserUIContext.getMessage(ProjectI18nEnum.FORM_LEADER) + ": " + leadAvatar.write())
                .withWidthUndefined();
        footer.addComponents(leadLbl);
    }
    if (project.getHomepage() != null) {
        ELabel homepageLbl = ELabel
                .html(FontAwesome.WECHAT.getHtml() + " " + new A(project.getHomepage())
                        .appendText(project.getHomepage()).setTarget("_blank").write())
                .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
        homepageLbl.setDescription(UserUIContext.getMessage(ProjectI18nEnum.FORM_HOME_PAGE));
    }

    if (project.getNumActiveMembers() > 0) {
        ELabel activeMembersLbl = ELabel.html(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers())
                .withDescription(UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_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.getEntityLogoPath(MyCollabUI.getAccountId(),
                    project.getClientAvatarId(), 16)).setCSSClass(UIConstants.CIRCLE_BOX);
            clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE());
        }
        clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid()))
                .appendText(StringUtils.trim(project.getClientName(), 30, true)));
        ELabel accountBtn = ELabel.html(clientDiv.write()).withStyleName(WebThemes.BUTTON_LINK)
                .withWidthUndefined();
        footer.addComponents(accountBtn);
    }

    if (!SiteConfiguration.isCommunityEdition()) {
        MButton tagBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null)))
                        .withIcon(FontAwesome.TAGS)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(tagBtn);

        MButton favoriteBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null)))
                        .withIcon(FontAwesome.STAR)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(favoriteBtn);

        MButton eventBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this)))
                        .withIcon(FontAwesome.CALENDAR)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(eventBtn);

        MButton ganttChartBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null)))
                        .withIcon(FontAwesome.BAR_CHART_O)
                        .withStyleName(WebThemes.BUTTON_SMALL_PADDING, WebThemes.BUTTON_LINK);
        footer.addComponents(ganttChartBtn);
    }

    headerLayout.with(breadCrumb, footer);

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

    if (project.isProjectArchived()) {
        MButton activeProjectBtn = new MButton(
                UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT), clickEvent -> {
                    ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class);
                    project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Open.name());
                    projectService.updateSelectiveWithSession(project, UserUIContext.getUsername());

                    PageActionChain chain = new PageActionChain(
                            new ProjectScreenData.Goto(CurrentProjectVariables.getProjectId()));
                    EventBusFactory.getInstance().post(new ProjectEvent.GotoMyProject(this, chain));
                }).withStyleName(WebThemes.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(WebThemes.BOX);
        controlsBtn.setIcon(FontAwesome.ELLIPSIS_H);

        OptionPopupContent popupButtonsControl = new OptionPopupContent();

        if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS)) {
            MButton inviteMemberBtn = new MButton(
                    UserUIContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES), clickEvent -> {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectMemberEvent.GotoInviteMembers(this, null));
                    }).withIcon(FontAwesome.SEND);
            popupButtonsControl.addOption(inviteMemberBtn);
        }

        MButton settingBtn = new MButton(UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS),
                clickEvent -> {
                    controlsBtn.setPopupVisible(false);
                    EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null));
                }).withIcon(FontAwesome.COG);
        popupButtonsControl.addOption(settingBtn);

        popupButtonsControl.addSeparator();

        if (UserUIContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT)) {
            final MButton markProjectTemplateBtn = new MButton().withIcon(FontAwesome.ANCHOR);
            markProjectTemplateBtn.addClickListener(clickEvent -> {
                Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
                project.setIstemplate(isTemplate);
                ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class);
                prjService.updateWithSession(project, UserUIContext.getUsername());
                if (project.getIstemplate()) {
                    markProjectTemplateBtn
                            .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
                } else {
                    markProjectTemplateBtn
                            .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
                }
            });

            Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
            if (isTemplate) {
                markProjectTemplateBtn
                        .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
            } else {
                markProjectTemplateBtn
                        .setCaption(UserUIContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
            }
            popupButtonsControl.addOption(markProjectTemplateBtn);
        }

        if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT)) {
            MButton editProjectBtn = new MButton(UserUIContext.getMessage(ProjectI18nEnum.EDIT), clickEvent -> {
                controlsBtn.setPopupVisible(false);
                EventBusFactory.getInstance()
                        .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project));
            }).withIcon(FontAwesome.EDIT);
            popupButtonsControl.addOption(editProjectBtn);
        }

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            MButton archiveProjectBtn = new MButton(
                    UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT), clickEvent -> {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                UserUIContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE,
                                        MyCollabUI.getSiteName()),
                                UserUIContext.getMessage(
                                        ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_ARCHIVE_MESSAGE),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                                    if (confirmDialog.isConfirmed()) {
                                        ProjectService projectService = AppContextUtil
                                                .getSpringBean(ProjectService.class);
                                        project.setProjectstatus(OptionI18nEnum.StatusI18nEnum.Archived.name());
                                        projectService.updateSelectiveWithSession(project,
                                                UserUIContext.getUsername());

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

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            popupButtonsControl.addSeparator();
            MButton deleteProjectBtn = new MButton(
                    UserUIContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT), clickEvent -> {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                        MyCollabUI.getSiteName()),
                                UserUIContext.getMessage(
                                        ProjectCommonI18nEnum.DIALOG_CONFIRM_PROJECT_DELETE_MESSAGE),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                                UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                                    if (confirmDialog.isConfirmed()) {
                                        ProjectService projectService = AppContextUtil
                                                .getSpringBean(ProjectService.class);
                                        projectService.removeWithSession(CurrentProjectVariables.getProject(),
                                                UserUIContext.getUsername(), MyCollabUI.getAccountId());
                                        EventBusFactory.getInstance()
                                                .post(new ShellEvent.GotoProjectModule(this, null));
                                    }
                                });
                    }).withIcon(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.mycollab.module.project.view.user.ProjectPagedList.java

License:Open Source License

@Override
protected MHorizontalLayout createPageControls() {
    MHorizontalLayout pageControls = super.createPageControls();
    if (pageControls != null) {
        Button browseProjectsBtn = new Button(UserUIContext.getMessage(ProjectI18nEnum.ACTION_BROWSE),
                clickEvent -> EventBusFactory.getInstance().post(new ProjectEvent.GotoList(this, null)));
        browseProjectsBtn.addStyleName(WebThemes.BUTTON_LINK);
        pageControls.addComponent(browseProjectsBtn, 0);
        pageControls.setComponentAlignment(browseProjectsBtn, Alignment.MIDDLE_LEFT);
    }/*from w  w  w . j a  va2s  .c  om*/
    return pageControls;
}

From source file:com.mycollab.module.project.view.UserDashboardViewImpl.java

License:Open Source License

private void displaySearchResult(String value) {
    removeAllComponents();//from  w  w w  .  j a v  a 2  s  .  c o  m
    Component headerWrapper = setupHeader();

    MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    with(headerWrapper, layout).expand(layout);

    MHorizontalLayout headerComp = new MHorizontalLayout();
    ELabel headerLbl = ELabel.h2(String.format(headerTitle, value, 0));
    Button backDashboard = new Button("Back to workboard", clickEvent -> showDashboard());
    backDashboard.setStyleName(WebThemes.BUTTON_ACTION);
    headerComp.with(headerLbl, backDashboard).alignAll(Alignment.MIDDLE_LEFT);
    layout.with(headerComp);

    ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class);
    prjKeys = prjService.getProjectKeysUserInvolved(UserUIContext.getUsername(), MyCollabUI.getAccountId());
    if (CollectionUtils.isNotEmpty(prjKeys)) {
        ProjectGenericItemSearchCriteria searchCriteria = new ProjectGenericItemSearchCriteria();
        searchCriteria.setPrjKeys(new SetSearchField<>(prjKeys.toArray(new Integer[prjKeys.size()])));
        searchCriteria.setTxtValue(StringSearchField.and(value));

        DefaultBeanPagedList<ProjectGenericItemService, ProjectGenericItemSearchCriteria, ProjectGenericItem> searchItemsTable = new DefaultBeanPagedList<>(
                AppContextUtil.getSpringBean(ProjectGenericItemService.class),
                new GenericItemRowDisplayHandler());
        searchItemsTable.setControlStyle("borderlessControl");
        int foundNum = searchItemsTable.setSearchCriteria(searchCriteria);
        headerLbl.setValue(String.format(headerTitle, value, foundNum));
        layout.with(searchItemsTable).expand(searchItemsTable);
    }
}

From source file:com.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java

License:Open Source License

@Override
public void displayView() {
    removeAllComponents();/*from  ww  w  .j a  v a  2  s.  c om*/

    billingAccount = MyCollabUI.getBillingAccount();
    FormContainer formContainer = new FormContainer();
    this.addComponent(formContainer);

    MHorizontalLayout generalSettingHeader = new MHorizontalLayout();
    Label headerLbl = new Label(UserUIContext.getMessage(AdminI18nEnum.OPT_GENERAL_SETTINGS));

    MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            clickEvent -> UI.getCurrent().addWindow(new AccountInfoChangeWindow()))
                    .withStyleName(WebThemes.BUTTON_LINK);

    generalSettingHeader.with(headerLbl, editBtn).alignAll(Alignment.MIDDLE_LEFT);

    GridFormLayoutHelper gridFormLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 5, "200px");
    gridFormLayoutHelper.addComponent(new Label(billingAccount.getSitename()),
            UserUIContext.getMessage(AdminI18nEnum.FORM_SITE_NAME), 0, 0);
    gridFormLayoutHelper.addComponent(
            new Label(String.format("https://%s.mycollab.com", billingAccount.getSubdomain())),
            UserUIContext.getMessage(AdminI18nEnum.FORM_SITE_ADDRESS), 0, 1);
    gridFormLayoutHelper.addComponent(
            new Label(TimezoneVal.getDisplayName(UserUIContext.getUserLocale(),
                    billingAccount.getDefaulttimezone())),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0, 2);
    Currency defaultCurrency = billingAccount.getCurrencyInstance();
    gridFormLayoutHelper.addComponent(new ELabel(defaultCurrency.getDisplayName(UserUIContext.getUserLocale())),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_CURRENCY), 0, 3);

    Date now = new GregorianCalendar().getTime();
    String defaultFullDateFormat = billingAccount.getDateFormatInstance();
    gridFormLayoutHelper.addComponent(
            new Label(String.format("%s (%s)",
                    DateTimeUtils.formatDate(now, billingAccount.getDateFormatInstance(),
                            UserUIContext.getUserLocale()),
                    defaultFullDateFormat)),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
            UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 0);

    String defaultShortDateFormat = billingAccount.getShortDateFormatInstance();
    gridFormLayoutHelper.addComponent(
            new Label(String.format("%s (%s)",
                    DateTimeUtils.formatDate(now, billingAccount.getShortDateFormatInstance(),
                            UserUIContext.getUserLocale()),
                    defaultShortDateFormat)),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
            UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 1);

    String defaultLongDateFormat = billingAccount.getLongDateFormatInstance();
    gridFormLayoutHelper.addComponent(
            new Label(String.format("%s (%s)",
                    DateTimeUtils.formatDate(now, billingAccount.getLongDateFormatInstance(),
                            UserUIContext.getUserLocale()),
                    defaultLongDateFormat)),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
            UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 1, 2);

    gridFormLayoutHelper.addComponent(
            new Label(LocalizationHelper.getLocaleInstance(billingAccount.getDefaultlanguagetag())
                    .getDisplayLanguage(UserUIContext.getUserLocale())),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 1, 3);

    gridFormLayoutHelper.addComponent(
            new Label(UserUIContext
                    .getMessage(LocalizationHelper.localizeYesNo(billingAccount.getDisplayemailpublicly()))),
            UserUIContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY),
            UserUIContext.getMessage(AdminI18nEnum.FORM_SHOW_EMAIL_PUBLICLY_HELP), 0, 4, 2, "100%");

    formContainer.addSection(new CssLayout(generalSettingHeader), gridFormLayoutHelper.getLayout());

    buildLogoPanel();
    buildShortcutIconPanel();

    if (!SiteConfiguration.isDemandEdition()) {
        buildLanguageUpdatePanel();
    }
}