Example usage for com.vaadin.ui VerticalLayout addComponent

List of usage examples for com.vaadin.ui VerticalLayout addComponent

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

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

License:Open Source License

private void displayAdvancedView() {

    if (this.getComponentCount() > 1) {
        this.removeComponent(this.getComponent(1));
    }//from  w w  w .  ja v  a  2 s  .  co  m

    final HorizontalLayout bodyLayout = new HorizontalLayout();
    bodyLayout.setSpacing(false);
    bodyLayout.setWidth("100%");
    final VerticalLayout leftColumn = new VerticalLayout();
    leftColumn.setMargin(new MarginInfo(false, true, false, false));
    bodyLayout.addComponent(leftColumn);
    bodyLayout.setExpandRatio(leftColumn, 1.0f);
    final VerticalLayout rightColumn = new VerticalLayout();
    bodyLayout.addComponent(rightColumn);

    final UnresolvedBugsByPriorityWidget unresolvedBugWidget = new UnresolvedBugsByPriorityWidget(this);
    unresolvedBugWidget.setWidth("100%");
    leftColumn.addComponent(unresolvedBugWidget);

    final BugSearchCriteria unresolvedByPrioritySearchCriteria = new BugSearchCriteria();
    unresolvedByPrioritySearchCriteria
            .setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
    unresolvedByPrioritySearchCriteria.setMilestoneIds(new SetSearchField<Integer>(this.milestone.getId()));
    unresolvedByPrioritySearchCriteria.setStatuses(new SetSearchField<String>(SearchField.AND,
            new String[] { BugStatus.InProgress.name(), BugStatus.Open.name(), BugStatus.ReOpened.name() }));
    unresolvedBugWidget.setSearchCriteria(unresolvedByPrioritySearchCriteria);

    final UnresolvedBugsByAssigneeWidget unresolvedByAssigneeWidget = new UnresolvedBugsByAssigneeWidget(this);
    unresolvedByAssigneeWidget.setWidth("100%");
    leftColumn.addComponent(unresolvedByAssigneeWidget);

    final BugSearchCriteria unresolvedByAssigneeSearchCriteria = new BugSearchCriteria();
    unresolvedByAssigneeSearchCriteria
            .setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
    unresolvedByAssigneeSearchCriteria.setMilestoneIds(new SetSearchField<Integer>(this.milestone.getId()));
    unresolvedByAssigneeSearchCriteria.setStatuses(new SetSearchField<String>(SearchField.AND,
            new String[] { BugStatus.InProgress.name(), BugStatus.Open.name(), BugStatus.ReOpened.name() }));
    unresolvedByAssigneeWidget.setSearchCriteria(unresolvedByAssigneeSearchCriteria);

    final BugSearchCriteria chartSearchCriteria = new BugSearchCriteria();
    chartSearchCriteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
    chartSearchCriteria.setMilestoneIds(new SetSearchField<Integer>(this.milestone.getId()));
    BugChartComponent bugChartComponent = null;
    bugChartComponent = new BugChartComponent(chartSearchCriteria, 400, 200);
    rightColumn.addComponent(bugChartComponent);
    rightColumn.setWidth("400px");

    this.addComponent(bodyLayout);
}

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

License:Open Source License

@Override
public Layout getLayout() {
    final VerticalLayout layout = new VerticalLayout();

    this.informationLayout = new GridFormLayoutHelper(2, 5, "100%", "145px", Alignment.TOP_LEFT);
    this.informationLayout.getLayout().setWidth("100%");
    this.informationLayout.getLayout().addStyleName("colored-gridlayout");
    this.informationLayout.getLayout().setMargin(false);
    layout.addComponent(this.informationLayout.getLayout());
    layout.setComponentAlignment(this.informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    return layout;
}

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

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();

    this.informationLayout = new GridFormLayoutHelper(2, 3, "100%", "167px", Alignment.TOP_LEFT);
    this.informationLayout.getLayout().setWidth("100%");
    this.informationLayout.getLayout().setMargin(false);
    this.informationLayout.getLayout().addStyleName("colored-gridlayout");
    layout.addComponent(this.informationLayout.getLayout());
    layout.setComponentAlignment(this.informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    return layout;
}

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

License:Open Source License

private Layout displayFolderBlock(final Folder resource) {
    MHorizontalLayout container = new MHorizontalLayout().withWidth("100%").withStyleName("page-item-block");

    FontIconLabel iconResource = new FontIconLabel(FontAwesome.FOLDER_OPEN);
    iconResource.addStyleName("icon-48px");

    VerticalLayout block = new VerticalLayout();
    block.setWidth("600px");
    HorizontalLayout headerPanel = new HorizontalLayout();
    Button folderLink = new Button(resource.getName(), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from w  ww.j  a va2  s.  c  o m
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new PageEvent.GotoList(PageListViewImpl.this, resource.getPath()));

        }
    });
    folderLink.addStyleName("link");
    folderLink.addStyleName("h3");
    headerPanel.addComponent(folderLink);
    block.addComponent(headerPanel);
    block.addComponent(new Label(StringUtils.trimHtmlTags(resource.getDescription())));

    Label lastUpdateInfo = new Label(AppContext.getMessage(Page18InEnum.LABEL_LAST_UPDATE,
            ProjectLinkBuilder.generateProjectMemberHtmlLink(resource.getCreatedUser(),
                    CurrentProjectVariables.getProjectId()),
            AppContext.formatDateTime(resource.getCreatedTime().getTime())), ContentMode.HTML);
    lastUpdateInfo.addStyleName("last-update-info");
    block.addComponent(lastUpdateInfo);

    MHorizontalLayout controlBtns = new MHorizontalLayout().withStyleName("control-btns");
    Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() {

        private static final long serialVersionUID = -5387015552598157076L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent().addWindow(new PageGroupWindow(resource));
        }
    });
    editBtn.setIcon(FontAwesome.EDIT);
    editBtn.setStyleName("link");
    editBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    controlBtns.addComponent(editBtn);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {

                private static final long serialVersionUID = -5387015552598157076L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                    SiteConfiguration.getSiteName()),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                            AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                            AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        PageService wikiService = ApplicationContextUtil
                                                .getSpringBean(PageService.class);
                                        wikiService.removeResource(resource.getPath());
                                        resources.remove(resource);
                                        displayPages(resources);
                                    }
                                }
                            });

                }
            });
    deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES));
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.setStyleName("link");
    controlBtns.addComponent(deleteBtn);

    block.addComponent(controlBtns);

    HorizontalLayout footer = new HorizontalLayout();
    block.addComponent(footer);

    MHorizontalLayout wrapper = new MHorizontalLayout();
    wrapper.with(iconResource, block);
    container.with(wrapper);
    return container;
}

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

License:Open Source License

private Layout displayPageBlock(final Page resource) {
    MHorizontalLayout container = new MHorizontalLayout().withWidth("100%").withStyleName("page-item-block");

    FontIconLabel iconResource = new FontIconLabel(FontAwesome.FILE_WORD_O);
    iconResource.addStyleName("icon-48px");

    VerticalLayout block = new VerticalLayout();
    block.setWidth("600px");
    HorizontalLayout headerPanel = new HorizontalLayout();
    Button pageLink = new Button(resource.getSubject(), new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override/*from ww  w. j  a  va  2  s . com*/
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new PageEvent.GotoRead(PageListViewImpl.this, resource));

        }
    });
    pageLink.addStyleName("link");
    pageLink.addStyleName("h3");
    headerPanel.addComponent(pageLink);

    block.addComponent(headerPanel);

    block.addComponent(new Label(StringUtils.trimHtmlTags(resource.getContent())));

    Label lastUpdateInfo = new Label(AppContext.getMessage(Page18InEnum.LABEL_LAST_UPDATE,
            ProjectLinkBuilder.generateProjectMemberHtmlLink(resource.getLastUpdatedUser(),
                    CurrentProjectVariables.getProjectId()),
            AppContext.formatDateTime(resource.getLastUpdatedTime().getTime())), ContentMode.HTML);
    lastUpdateInfo.addStyleName("last-update-info");
    block.addComponent(lastUpdateInfo);

    MHorizontalLayout controlBtns = new MHorizontalLayout().withStyleName("control-btns");
    Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() {

        private static final long serialVersionUID = -5387015552598157076L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new PageEvent.GotoEdit(PageListViewImpl.this, resource));
        }
    });
    editBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));
    editBtn.setIcon(FontAwesome.EDIT);
    editBtn.setStyleName("link");
    controlBtns.addComponent(editBtn);

    Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE),
            new Button.ClickListener() {

                private static final long serialVersionUID = 2575434171770462361L;

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    ConfirmDialogExt.show(UI.getCurrent(),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                    SiteConfiguration.getSiteName()),
                            AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                            AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                            AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                                private static final long serialVersionUID = 1L;

                                @Override
                                public void onClose(ConfirmDialog dialog) {
                                    if (dialog.isConfirmed()) {
                                        PageService wikiService = ApplicationContextUtil
                                                .getSpringBean(PageService.class);
                                        wikiService.removeResource(resource.getPath());
                                        resources.remove(resource);
                                        displayPages(resources);
                                    }
                                }
                            });

                }
            });
    deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES));
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.setStyleName("link");
    controlBtns.addComponent(deleteBtn);

    block.addComponent(controlBtns);

    MHorizontalLayout wrapper = new MHorizontalLayout();
    wrapper.with(iconResource, block);
    container.with(wrapper);
    return container;
}

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

License:Open Source License

@Override
public void initView(final SimpleProject project) {
    this.removeAllComponents();
    updateVerticalTabsheetFixStatus();//from   ww  w .  j ava 2 s .c  o  m
    ControllerRegistry.addController(new ProjectController(this));
    this.setWidth("100%");

    this.addStyleName("main-content-wrapper");
    this.addStyleName("projectDashboardView");

    myProjectTab = new ProjectVerticalTabsheet();
    myProjectTab.setSizeFull();
    myProjectTab.setNavigatorWidth("100%");
    myProjectTab.setNavigatorStyleName("sidebar-menu");
    myProjectTab.setContainerStyleName("tab-content");

    myProjectTab.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            Tab tab = ((ProjectVerticalTabsheet) event.getSource()).getSelectedTab();
            String caption = ((TabImpl) tab).getTabId();
            if (ProjectTypeConstants.MESSAGE.equals(caption)) {
                messagePresenter.go(ProjectViewImpl.this, null);
            } else if (ProjectTypeConstants.MILESTONE.equals(caption)) {
                MilestoneSearchCriteria searchCriteria = new MilestoneSearchCriteria();
                searchCriteria.setProjectId(
                        new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProjectId()));
                gotoMilestoneView(new MilestoneScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.TASK.equals(caption)) {
                taskPresenter.go(ProjectViewImpl.this, null);
            } else if (ProjectTypeConstants.BUG.equals(caption)) {
                gotoBugView(null);
            } else if (ProjectTypeConstants.RISK.equals(caption)) {
                RiskSearchCriteria searchCriteria = new RiskSearchCriteria();
                searchCriteria.setProjectId(
                        new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProjectId()));
                gotoRiskView(new RiskScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.FILE.equals(caption)) {
                filePresenter.go(ProjectViewImpl.this, new FileScreenData.GotoDashboard());
            } else if (ProjectTypeConstants.PAGE.equals(caption)) {
                pagePresenter.go(ProjectViewImpl.this,
                        new PageScreenData.Search(CurrentProjectVariables.getBasePagePath()));
            } else if (ProjectTypeConstants.PROBLEM.equals(caption)) {
                ProblemSearchCriteria searchCriteria = new ProblemSearchCriteria();
                searchCriteria.setProjectId(
                        new NumberSearchField(SearchField.AND, CurrentProjectVariables.getProjectId()));
                problemPresenter.go(ProjectViewImpl.this, new ProblemScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.DASHBOARD.equals(caption)) {
                dashboardPresenter.go(ProjectViewImpl.this, null);
            } else if (ProjectTypeConstants.MEMBER.equals(caption)) {
                ProjectMemberSearchCriteria criteria = new ProjectMemberSearchCriteria();
                criteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
                criteria.setStatus(new StringSearchField(ProjectMemberStatusConstants.ACTIVE));
                gotoUsersAndGroup(new ProjectMemberScreenData.Search(criteria));
            } else if (ProjectTypeConstants.TIME.equals(caption)) {
                ItemTimeLoggingSearchCriteria searchCriteria = new ItemTimeLoggingSearchCriteria();
                searchCriteria.setProjectIds(new SetSearchField<>(CurrentProjectVariables.getProjectId()));
                searchCriteria
                        .setRangeDate(ItemTimeLoggingSearchCriteria.getCurrentRangeDateOfWeekSearchField());
                gotoTimeTrackingView(new TimeTrackingScreenData.Search(searchCriteria));
            } else if (ProjectTypeConstants.STANDUP.equals(caption)) {
                StandupReportSearchCriteria criteria = new StandupReportSearchCriteria();
                criteria.setProjectId(new NumberSearchField(CurrentProjectVariables.getProjectId()));
                criteria.setOnDate(new DateSearchField(SearchField.AND, DateSearchField.EQUAL,
                        new GregorianCalendar().getTime()));
                standupPresenter.go(ProjectViewImpl.this, new StandupScreenData.Search(criteria));
            }

        }
    });

    VerticalLayout contentWrapper = myProjectTab.getContentWrapper();
    contentWrapper.addStyleName("main-content");
    MHorizontalLayout topPanel = new MHorizontalLayout().withSpacing(false).withMargin(true).withWidth("100%")
            .withStyleName("top-panel");
    contentWrapper.addComponentAsFirst(topPanel);

    ProjectListComponent prjList = new ProjectListComponent();
    CssLayout navigatorWrapper = myProjectTab.getNavigatorWrapper();
    navigatorWrapper.addComponentAsFirst(prjList);
    navigatorWrapper.setWidth("250px");

    buildComponents();
    this.addComponent(myProjectTab);

    ProjectBreadcrumb breadCrumb = ViewManager.getCacheComponent(ProjectBreadcrumb.class);
    breadCrumb.setProject(project);

    topPanel.with(breadCrumb).withAlign(breadCrumb, Alignment.MIDDLE_LEFT).expand(breadCrumb);

    if (project.isProjectArchived()) {
        Button activeProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT),
                new ClickListener() {

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ProjectService projectService = ApplicationContextUtil
                                .getSpringBean(ProjectService.class);
                        project.setProjectstatus(StatusI18nEnum.Open.name());
                        projectService.updateSelectiveWithSession(project, AppContext.getUsername());

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

                    }
                });
        activeProjectBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
        topPanel.with(activeProjectBtn).withAlign(activeProjectBtn, Alignment.MIDDLE_RIGHT);
    } else {
        final PopupButton controlsBtn = new PopupButton();
        controlsBtn.setIcon(FontAwesome.ELLIPSIS_H);
        controlsBtn.addStyleName(UIConstants.THEME_BLANK_LINK);

        VerticalLayout popupButtonsControl = new VerticalLayout();
        popupButtonsControl.setSpacing(true);
        popupButtonsControl.setWidth("150px");

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

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

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

        Button createRiskBtn = new Button(AppContext.getMessage(RiskI18nEnum.BUTTON_NEW_RISK),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new RiskEvent.GotoAdd(this, null));
                    }
                });
        createRiskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS));
        createRiskBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.RISK));
        createRiskBtn.setStyleName("link");
        popupButtonsControl.addComponent(createRiskBtn);

        Button createProblemBtn = new Button(AppContext.getMessage(ProblemI18nEnum.BUTTON_NEW_PROBLEM),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new ProblemEvent.GotoAdd(this, null));
                    }
                });
        createProblemBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROBLEMS));
        createProblemBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.PROBLEM));
        createProblemBtn.setStyleName("link");
        popupButtonsControl.addComponent(createProblemBtn);

        Button editProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_EDIT_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        dashboardPresenter.go(ProjectViewImpl.this, new ProjectScreenData.Edit(project));
                    }
                });
        editProjectBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT));
        editProjectBtn.setIcon(FontAwesome.EDIT);
        editProjectBtn.setStyleName("link");
        popupButtonsControl.addComponent(editProjectBtn);

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

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

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

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

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

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

        topPanel.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
    }

    prjList.showProjects();
}

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

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    final Label organizationHeader = new Label(
            AppContext.getMessage(ProjectMemberI18nEnum.FORM_INFORMATION_SECTION));
    organizationHeader.setStyleName("h2");
    layout.addComponent(organizationHeader);

    this.informationLayout = new GridFormLayoutHelper(1, 2, "100%", "167px", Alignment.TOP_LEFT);
    this.informationLayout.getLayout().setWidth("100%");
    this.informationLayout.getLayout().setMargin(false);
    this.informationLayout.getLayout().addStyleName("colored-gridlayout");

    layout.addComponent(this.informationLayout.getLayout());
    return layout;
}

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

License:Open Source License

private Layout createBottomPanel() {
    VerticalLayout permissionsPanel = new VerticalLayout();
    final Label organizationHeader = new Label(AppContext.getMessage(ProjectRoleI18nEnum.SECTION_PERMISSIONS));
    organizationHeader.setStyleName("h2");
    permissionsPanel.addComponent(organizationHeader);

    projectFormHelper = new GridFormLayoutHelper(2, ProjectRolePermissionCollections.PROJECT_PERMISSIONS.length,
            "100%", "167px", Alignment.TOP_LEFT);
    projectFormHelper.getLayout().setWidth("100%");
    projectFormHelper.getLayout().setMargin(false);
    projectFormHelper.getLayout().addStyleName("colored-gridlayout");

    permissionsPanel.addComponent(projectFormHelper.getLayout());

    roleId = (Integer) roleComboBox.getValue();
    displayRolePermission(roleId);//from   w  w w .j av a 2s  .  c  om

    return permissionsPanel;
}

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

License:Open Source License

private Component generateMemberBlock(final SimpleProjectMember member) {
    CssLayout memberBlock = new CssLayout();
    memberBlock.addStyleName("member-block");

    VerticalLayout blockContent = new VerticalLayout();
    MHorizontalLayout blockTop = new MHorizontalLayout();
    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(),
            100);/*w w w  .jav  a2  s. c o m*/
    blockTop.addComponent(memberAvatar);

    VerticalLayout memberInfo = new VerticalLayout();

    Button deleteBtn = new Button("", FontAwesome.TRASH_O);
    deleteBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                ProjectMemberService prjMemberService = ApplicationContextUtil
                                        .getSpringBean(ProjectMemberService.class);
                                member.setStatus(ProjectMemberStatusConstants.INACTIVE);
                                prjMemberService.updateWithSession(member, AppContext.getUsername());

                                EventBusFactory.getInstance().post(
                                        new ProjectMemberEvent.GotoList(ProjectMemberListViewImpl.this, null));
                            }
                        }
                    });
        }
    });
    deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);

    blockContent.addComponent(deleteBtn);
    deleteBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
    blockContent.setComponentAlignment(deleteBtn, Alignment.TOP_RIGHT);

    LabelLink memberLink = new LabelLink(member.getMemberFullName(),
            ProjectLinkBuilder.generateProjectMemberFullLink(member.getProjectid(), member.getUsername()));

    memberLink.setWidth("100%");
    memberLink.addStyleName("member-name");

    memberInfo.addComponent(memberLink);

    String roleLink = "<a href=\"" + AppContext.getSiteUrl() + GenericLinkUtils.URL_PREFIX_PARAM
            + ProjectLinkGenerator.generateRolePreviewLink(member.getProjectid(), member.getProjectRoleId())
            + "\"";
    Label memberRole = new Label();
    memberRole.setContentMode(ContentMode.HTML);
    memberRole.setStyleName("member-role");
    if (member.isAdmin()) {
        memberRole.setValue(roleLink + "style=\"color: #B00000;\">" + "Project Admin" + "</a>");
    } else {
        memberRole.setValue(roleLink + "style=\"color:gray;font-size:12px;\">" + member.getRoleName() + "</a>");
    }
    memberRole.setSizeUndefined();
    memberInfo.addComponent(memberRole);

    Label memberEmailLabel = new Label(
            "<a href='mailto:" + member.getUsername() + "'>" + member.getUsername() + "</a>", ContentMode.HTML);
    memberEmailLabel.addStyleName("member-email");
    memberEmailLabel.setWidth("100%");
    memberInfo.addComponent(memberEmailLabel);

    Label memberSinceLabel = new Label("Member since: " + AppContext.formatDate(member.getJoindate()));
    memberSinceLabel.addStyleName("member-email");
    memberSinceLabel.setWidth("100%");
    memberInfo.addComponent(memberSinceLabel);

    if (RegisterStatusConstants.SENT_VERIFICATION_EMAIL.equals(member.getStatus())) {
        final VerticalLayout waitingNotLayout = new VerticalLayout();
        Label infoStatus = new Label(AppContext.getMessage(ProjectMemberI18nEnum.WAITING_ACCEPT_INVITATION));
        infoStatus.addStyleName("member-email");
        waitingNotLayout.addComponent(infoStatus);

        ButtonLink resendInvitationLink = new ButtonLink(
                AppContext.getMessage(ProjectMemberI18nEnum.BUTTON_RESEND_INVITATION),
                new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ProjectMemberMapper projectMemberMapper = ApplicationContextUtil
                                .getSpringBean(ProjectMemberMapper.class);
                        member.setStatus(RegisterStatusConstants.VERIFICATING);
                        projectMemberMapper.updateByPrimaryKeySelective(member);
                        waitingNotLayout.removeAllComponents();
                        Label statusEmail = new Label(
                                AppContext.getMessage(ProjectMemberI18nEnum.SENDING_EMAIL_INVITATION));
                        statusEmail.addStyleName("member-email");
                        waitingNotLayout.addComponent(statusEmail);
                    }
                });
        resendInvitationLink.setStyleName("link");
        resendInvitationLink.addStyleName("member-email");
        waitingNotLayout.addComponent(resendInvitationLink);
        memberInfo.addComponent(waitingNotLayout);
    } else if (RegisterStatusConstants.ACTIVE.equals(member.getStatus())) {
        Label lastAccessTimeLbl = new Label("Logged in "
                + DateTimeUtils.getPrettyDateValue(member.getLastAccessTime(), AppContext.getUserLocale()));
        lastAccessTimeLbl.addStyleName("member-email");
        memberInfo.addComponent(lastAccessTimeLbl);
    } else if (RegisterStatusConstants.VERIFICATING.equals(member.getStatus())) {
        Label infoStatus = new Label(AppContext.getMessage(ProjectMemberI18nEnum.SENDING_EMAIL_INVITATION));
        infoStatus.addStyleName("member-email");
        memberInfo.addComponent(infoStatus);
    }

    String bugStatus = member.getNumOpenBugs() + " open bug";
    if (member.getNumOpenBugs() > 1) {
        bugStatus += "s";
    }

    String taskStatus = member.getNumOpenTasks() + " open task";
    if (member.getNumOpenTasks() > 1) {
        taskStatus += "s";
    }

    Label memberWorkStatus = new Label(bugStatus + " - " + taskStatus);
    memberInfo.addComponent(memberWorkStatus);
    memberInfo.setWidth("100%");

    blockTop.addComponent(memberInfo);
    blockTop.setExpandRatio(memberInfo, 1.0f);
    blockTop.setWidth("100%");
    blockContent.addComponent(blockTop);

    blockContent.setWidth("100%");

    memberBlock.addComponent(blockContent);
    return memberBlock;
}

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

License:Open Source License

public ProjectNotificationSettingViewComponent(final ProjectNotificationSetting bean) {
    super(AppContext.getMessage(ProjectSettingI18nEnum.VIEW_TITLE));

    VerticalLayout bodyWrapper = new VerticalLayout();
    bodyWrapper.setSpacing(true);//w w  w  . j av  a  2s  .  c  o m
    bodyWrapper.setMargin(true);
    bodyWrapper.setSizeFull();

    HorizontalLayout notificationLabelWrapper = new HorizontalLayout();
    notificationLabelWrapper.setSizeFull();
    notificationLabelWrapper.setMargin(true);

    notificationLabelWrapper.setStyleName("notification-label");

    Label notificationLabel = new Label(AppContext.getMessage(ProjectSettingI18nEnum.EXT_LEVEL));
    notificationLabel.addStyleName("h2");

    notificationLabel.setHeightUndefined();
    notificationLabelWrapper.addComponent(notificationLabel);

    bodyWrapper.addComponent(notificationLabelWrapper);

    VerticalLayout body = new VerticalLayout();
    body.setSpacing(true);
    body.setMargin(new MarginInfo(true, false, false, false));

    final OptionGroup optionGroup = new OptionGroup(null);

    optionGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);

    optionGroup.addItem(NotificationType.Default.name());
    optionGroup.setItemCaption(NotificationType.Default.name(),
            AppContext.getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING));

    optionGroup.addItem(NotificationType.None.name());
    optionGroup.setItemCaption(NotificationType.None.name(),
            AppContext.getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING));

    optionGroup.addItem(NotificationType.Minimal.name());
    optionGroup.setItemCaption(NotificationType.Minimal.name(),
            AppContext.getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING));

    optionGroup.addItem(NotificationType.Full.name());
    optionGroup.setItemCaption(NotificationType.Full.name(),
            AppContext.getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING));

    optionGroup.setHeight("100%");

    body.addComponent(optionGroup);
    body.setExpandRatio(optionGroup, 1.0f);
    body.setComponentAlignment(optionGroup, Alignment.MIDDLE_LEFT);

    String levelVal = bean.getLevel();
    if (levelVal == null) {
        optionGroup.select(NotificationType.Default.name());
    } else {
        optionGroup.select(levelVal);
    }

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

                @Override
                public void buttonClick(ClickEvent event) {
                    try {
                        bean.setLevel((String) optionGroup.getValue());
                        ProjectNotificationSettingService projectNotificationSettingService = ApplicationContextUtil
                                .getSpringBean(ProjectNotificationSettingService.class);

                        if (bean.getId() == null) {
                            projectNotificationSettingService.saveWithSession(bean, AppContext.getUsername());
                        } else {
                            projectNotificationSettingService.updateWithSession(bean, AppContext.getUsername());
                        }
                        NotificationUtil.showNotification(
                                AppContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS));
                    } catch (Exception e) {
                        throw new MyCollabException(e);
                    }
                }
            });
    updateBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    updateBtn.setIcon(FontAwesome.REFRESH);
    body.addComponent(updateBtn);
    body.setComponentAlignment(updateBtn, Alignment.BOTTOM_LEFT);

    bodyWrapper.addComponent(body);
    this.addComponent(bodyWrapper);

}