Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

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

Introduction

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

Prototype

Alignment MIDDLE_RIGHT

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

Click Source Link

Usage

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

License:Open Source License

public FilterTaskViewImpl() {
    this.setMargin(new MarginInfo(false, true, true, true));
    final HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);/*from  ww w  . jav a2  s.  c o  m*/
    header.setMargin(new MarginInfo(true, false, true, false));
    header.setStyleName(UIConstants.HEADER_VIEW);
    header.setWidth("100%");
    Image titleIcon = new Image(null, MyCollabResource.newResource("icons/24/project/task.png"));

    headerText = new Label();
    headerText.setSizeUndefined();
    headerText.setStyleName(UIConstants.HEADER_TEXT);

    Button backtoTaskListBtn = 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));

                }
            });
    backtoTaskListBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    UiUtils.addComponent(header, titleIcon, Alignment.TOP_LEFT);
    UiUtils.addComponent(header, headerText, Alignment.MIDDLE_LEFT);
    UiUtils.addComponent(header, backtoTaskListBtn, Alignment.MIDDLE_RIGHT);
    header.setExpandRatio(headerText, 1.0f);

    this.addComponent(header);

    HorizontalLayout contentLayout = new HorizontalLayout();
    contentLayout.setWidth("100%");
    contentLayout.setSpacing(true);
    this.addComponent(contentLayout);

    this.taskTableDisplay = new TaskTableDisplay(Arrays.asList(TaskTableFieldDef.taskname,
            TaskTableFieldDef.startdate, TaskTableFieldDef.duedate, TaskTableFieldDef.percentagecomplete));

    this.taskTableDisplay.addTableListener(new TableClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(final TableClickEvent event) {
            final SimpleTask task = (SimpleTask) event.getData();
            if ("taskname".equals(event.getFieldName())) {
                EventBusFactory.getInstance()
                        .post(new TaskEvent.GotoRead(FilterTaskViewImpl.this, task.getId()));
            }
        }
    });
    taskTableDisplay.setWidth("100%");
    taskTableDisplay.setStyleName("filter-task-table");

    leftColumn = new VerticalLayout();
    leftColumn.addComponent(taskTableDisplay);
    leftColumn.setStyleName("depotComp");
    leftColumn.setMargin(new MarginInfo(true, true, false, false));

    rightColumn = new VerticalLayout();
    rightColumn.setWidth("300px");
    contentLayout.addComponent(leftColumn);
    contentLayout.addComponent(rightColumn);
    contentLayout.setExpandRatio(leftColumn, 1.0f);
    unresolvedTaskByAssigneeWidget = new UnresolvedTaskByAssigneeWidget();
    rightColumn.addComponent(unresolvedTaskByAssigneeWidget);

    unresolvedTaskByPriorityWidget = new UnresolvedTaskByPriorityWidget();
    rightColumn.addComponent(unresolvedTaskByPriorityWidget);
}

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

License:Open Source License

public TaskAddPopup(final TaskDisplayComponent taskDisplayComp, final TaskList taskList) {

    final VerticalLayout taskLayout = new VerticalLayout();
    taskLayout.addStyleName("taskadd-popup");

    final VerticalLayout popupHeader = new VerticalLayout();
    popupHeader.setWidth("100%");
    popupHeader.setMargin(true);/*ww  w .j  a v a 2 s  .c  o m*/
    popupHeader.addStyleName("popup-header");

    final Label titleLbl = new Label(AppContext.getMessage(TaskI18nEnum.DIALOG_NEW_TASK_TITLE));
    titleLbl.addStyleName("bold");
    popupHeader.addComponent(titleLbl);
    taskLayout.addComponent(popupHeader);

    this.task = new SimpleTask();
    TabSheet taskContainer = new TabSheet();
    final TaskInputForm taskInputForm = new TaskInputForm();
    taskInputForm.setWidth("100%");
    taskContainer.addTab(taskInputForm, AppContext.getMessage(GenericI18Enum.WINDOW_INFORMATION_TITLE));

    this.taskNoteComponent = new TaskNoteLayout();
    taskContainer.addTab(this.taskNoteComponent, AppContext.getMessage(TaskI18nEnum.FORM_NOTES_ATTACHMENT));

    taskLayout.addComponent(taskContainer);

    final MHorizontalLayout controlsLayout = new MHorizontalLayout().withMargin(true);
    controlsLayout.addStyleName("popup-footer");

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    taskDisplayComp.closeTaskAdd();
                }
            });

    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    if (taskInputForm.validateForm()) {
                        final ProjectTaskService taskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);

                        task.setTasklistid(taskList.getId());
                        task.setProjectid(CurrentProjectVariables.getProjectId());
                        task.setSaccountid(AppContext.getAccountId());
                        task.setNotes(taskNoteComponent.getNote());

                        taskService.saveWithSession(task, AppContext.getUsername());
                        taskNoteComponent.saveContentsToRepo(task.getId());
                        taskDisplayComp.saveTaskSuccess(task);
                        taskDisplayComp.closeTaskAdd();
                    }
                }
            });
    saveBtn.setIcon(FontAwesome.SAVE);
    saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK);

    controlsLayout.with(saveBtn, cancelBtn).alignAll(Alignment.MIDDLE_CENTER);

    taskLayout.addComponent(controlsLayout);
    taskLayout.setComponentAlignment(controlsLayout, Alignment.MIDDLE_RIGHT);

    this.setCompositionRoot(taskLayout);
}

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

License:Open Source License

private void showTaskGroupInfo() {
    if (this.isDisplayTaskListInfo) {
        AdvancedPreviewBeanForm<SimpleTaskList> previewForm = new AdvancedPreviewBeanForm<>();
        previewForm.setWidth("100%");
        previewForm.setFormLayoutFactory(new IFormLayoutFactory() {
            private static final long serialVersionUID = 1L;

            private GridFormLayoutHelper layoutHelper;

            @Override//from www  .  j  a  v  a  2 s. co  m
            public ComponentContainer getLayout() {
                this.layoutHelper = new GridFormLayoutHelper(2, 3, "100%", "180px", Alignment.TOP_LEFT);
                this.layoutHelper.getLayout().setWidth("100%");
                this.layoutHelper.getLayout().addStyleName("colored-gridlayout");
                this.layoutHelper.getLayout().setMargin(false);
                return this.layoutHelper.getLayout();
            }

            @Override
            public void attachField(Object propertyId, Field<?> field) {
                if ("description".equals(propertyId)) {
                    layoutHelper.addComponent(field, AppContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0,
                            0, 2, "100%");
                } else if ("owner".equals(propertyId)) {
                    layoutHelper.addComponent(field, AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE), 0, 1);
                } else if ("milestoneid".equals(propertyId)) {
                    layoutHelper.addComponent(field, AppContext.getMessage(TaskGroupI18nEnum.FORM_PHASE_FIELD),
                            1, 1);
                }
            }
        });
        previewForm.setBeanFormFieldFactory(
                new AbstractBeanFieldGroupViewFieldFactory<SimpleTaskList>(previewForm) {
                    private static final long serialVersionUID = 1L;

                    @Override
                    protected Field<?> onCreateField(Object propertyId) {
                        if ("description".equals(propertyId)) {
                            return new DefaultViewField(taskList.getDescription(), ContentMode.HTML);
                        } else if ("owner".equals(propertyId)) {
                            return new ProjectUserFormLinkField(taskList.getOwner(),
                                    taskList.getOwnerAvatarId(), taskList.getOwnerFullName());
                        } else if ("milestoneid".equals(propertyId)) {
                            return new LinkViewField(taskList.getMilestoneName(),
                                    ProjectLinkBuilder.generateMilestonePreviewFullLink(taskList.getProjectid(),
                                            taskList.getMilestoneid()),
                                    ProjectAssetsManager.getAsset(ProjectTypeConstants.MILESTONE));
                        }

                        return null;
                    }

                });
        this.addComponent(previewForm);

        previewForm.setBean(this.taskList);
    }

    this.taskDisplay = new TaskTableDisplay(TaskTableFieldDef.id,
            Arrays.asList(TaskTableFieldDef.taskname, TaskTableFieldDef.startdate, TaskTableFieldDef.duedate,
                    TaskTableFieldDef.assignee, TaskTableFieldDef.percentagecomplete));
    this.addComponent(this.taskDisplay);

    this.taskDisplay.addTableListener(new TableClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void itemClick(final TableClickEvent event) {
            final SimpleTask task = (SimpleTask) event.getData();
            if ("taskname".equals(event.getFieldName())) {
                EventBusFactory.getInstance()
                        .post(new TaskEvent.GotoRead(TaskDisplayComponent.this, task.getId()));
            } else if ("closeTask".equals(event.getFieldName()) || "reopenTask".equals(event.getFieldName())
                    || "pendingTask".equals(event.getFieldName())
                    || "deleteTask".equals(event.getFieldName())) {
                TaskDisplayComponent.this.removeAllComponents();
                final ProjectTaskListService taskListService = ApplicationContextUtil
                        .getSpringBean(ProjectTaskListService.class);
                TaskDisplayComponent.this.taskList = taskListService
                        .findById(TaskDisplayComponent.this.taskList.getId(), AppContext.getAccountId());
                TaskDisplayComponent.this.showTaskGroupInfo();
            }
        }
    });

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

                @Override
                public void buttonClick(final Button.ClickEvent event) {
                    TaskDisplayComponent.this
                            .removeComponent(TaskDisplayComponent.this.createTaskBtn.getParent());

                    TaskAddPopup taskAddView = new TaskAddPopup(TaskDisplayComponent.this,
                            TaskDisplayComponent.this.taskList);
                    TaskDisplayComponent.this.addComponent(taskAddView);
                }
            });
    this.createTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
    this.createTaskBtn.setIcon(FontAwesome.PLUS);
    this.createTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    final VerticalLayout taskGroupFooter = new VerticalLayout();
    taskGroupFooter.setMargin(true);
    taskGroupFooter.addStyleName("task-list-footer");
    taskGroupFooter.addComponent(this.createTaskBtn);
    taskGroupFooter.setComponentAlignment(this.createTaskBtn, Alignment.MIDDLE_RIGHT);
    this.addComponent(taskGroupFooter);

    if (CollectionUtils.isNotEmpty(taskList.getSubTasks())) {
        taskDisplay.setCurrentDataList(taskList.getSubTasks());
    } else {
        taskDisplay.setCurrentDataList(new ArrayList<SimpleTask>());
    }
}

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

License:Open Source License

public void closeTaskAdd() {
    final VerticalLayout taskGroupFooter = new VerticalLayout();
    taskGroupFooter.setMargin(true);//from w  ww  .  j av a2  s .  com
    taskGroupFooter.addStyleName("task-list-footer");
    taskGroupFooter.addComponent(this.createTaskBtn);
    taskGroupFooter.setComponentAlignment(this.createTaskBtn, Alignment.MIDDLE_RIGHT);
    this.addComponent(taskGroupFooter);

    Iterator<Component> comps = this.iterator();
    while (comps.hasNext()) {
        Component component = comps.next();
        if (component instanceof TaskAddPopup) {
            this.removeComponent(component);
            return;
        }
    }
}

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

License:Open Source License

private void constructUI() {
    this.removeAllComponents();
    this.withMargin(new MarginInfo(false, true, true, true));

    header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withStyleName("hdr-view").withWidth("100%");
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    this.taskGroupSelection = new PopupButton(
            AppContext.getMessage(TaskGroupI18nEnum.FILTER_ACTIVE_TASK_GROUPS_TITLE));
    this.taskGroupSelection.setEnabled(CurrentProjectVariables.canRead(ProjectRolePermissionCollections.TASKS));
    this.taskGroupSelection.addStyleName("link");
    this.taskGroupSelection.addStyleName("hdr-text");
    taskGroupSelection.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK_LIST));
    header.with(taskGroupSelection).withAlign(taskGroupSelection, Alignment.MIDDLE_LEFT)
            .expand(taskGroupSelection);

    final MVerticalLayout filterBtnLayout = new MVerticalLayout().withMargin(true).withSpacing(true)
            .withWidth("200px");

    final Button allTasksFilterBtn = new Button(
            AppContext.getMessage(TaskGroupI18nEnum.FILTER_ALL_TASK_GROUPS_TITLE), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//  w w w. j  a  v  a2  s  . co  m
                public void buttonClick(final ClickEvent event) {
                    TaskGroupDisplayViewImpl.this.taskGroupSelection.setPopupVisible(false);
                    TaskGroupDisplayViewImpl.this.taskGroupSelection
                            .setCaption(AppContext.getMessage(TaskGroupI18nEnum.FILTER_ALL_TASK_GROUPS_TITLE));
                    TaskGroupDisplayViewImpl.this.displayAllTaskGroups();
                }
            });
    allTasksFilterBtn.setStyleName("link");
    filterBtnLayout.addComponent(allTasksFilterBtn);

    final Button activeTasksFilterBtn = new Button(
            AppContext.getMessage(TaskGroupI18nEnum.FILTER_ACTIVE_TASK_GROUPS_TITLE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    TaskGroupDisplayViewImpl.this.taskGroupSelection.setPopupVisible(false);
                    TaskGroupDisplayViewImpl.this.taskGroupSelection.setCaption(
                            AppContext.getMessage(TaskGroupI18nEnum.FILTER_ACTIVE_TASK_GROUPS_TITLE));
                    TaskGroupDisplayViewImpl.this.displayActiveTaskGroups();
                }
            });
    activeTasksFilterBtn.setStyleName("link");
    filterBtnLayout.addComponent(activeTasksFilterBtn);

    final Button archivedTasksFilterBtn = new Button(
            AppContext.getMessage(TaskGroupI18nEnum.FILTER_ARCHIEVED_TASK_GROUPS_TITLE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    TaskGroupDisplayViewImpl.this.taskGroupSelection.setCaption(
                            AppContext.getMessage(TaskGroupI18nEnum.FILTER_ARCHIEVED_TASK_GROUPS_TITLE));
                    TaskGroupDisplayViewImpl.this.taskGroupSelection.setPopupVisible(false);
                    TaskGroupDisplayViewImpl.this.displayInActiveTaskGroups();
                }
            });
    archivedTasksFilterBtn.setStyleName("link");
    filterBtnLayout.addComponent(archivedTasksFilterBtn);

    this.taskGroupSelection.setContent(filterBtnLayout);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    final TaskGroupAddWindow taskListWindow = new TaskGroupAddWindow(
                            TaskGroupDisplayViewImpl.this);
                    UI.getCurrent().addWindow(taskListWindow);
                }
            });
    newTaskListBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
    newTaskListBtn.setIcon(FontAwesome.PLUS);
    newTaskListBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP));
    newTaskListBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    header.addComponent(newTaskListBtn);
    header.setComponentAlignment(newTaskListBtn, Alignment.MIDDLE_RIGHT);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskListEvent.ReoderTaskList(this, null));
        }
    });
    reOrderBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
    reOrderBtn.setIcon(FontAwesome.SORT);
    reOrderBtn.setStyleName(UIConstants.THEME_BLUE_LINK);
    reOrderBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_REODER_TASKGROUP));
    header.addComponent(reOrderBtn);
    header.setComponentAlignment(reOrderBtn, Alignment.MIDDLE_RIGHT);

    PopupButton exportButtonControl = new PopupButton();
    exportButtonControl.addStyleName(UIConstants.THEME_BLUE_LINK);
    exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK);
    exportButtonControl.setDescription("Export to file");

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

    Button exportPdfBtn = new Button(AppContext.getMessage(FileI18nEnum.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(AppContext.getMessage(FileI18nEnum.EXCEL));
    FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL));
    excelDownloader.extend(exportExcelBtn);
    exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O);
    exportExcelBtn.setStyleName("link");
    popupButtonsControl.addComponent(exportExcelBtn);

    header.with(exportButtonControl).withAlign(exportButtonControl, Alignment.MIDDLE_LEFT);

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

        @Override
        public void buttonClick(ClickEvent event) {
            displayAdvancedView();
        }
    });
    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(ClickEvent event) {
            TaskSearchCriteria searchCriteria = new TaskSearchCriteria();
            searchCriteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId()));
            searchCriteria.setStatuses(new SetSearchField<>(new String[] { StatusI18nEnum.Open.name() }));
            TaskFilterParameter taskFilter = new TaskFilterParameter(searchCriteria, "Task Search");
            taskFilter.setAdvanceSearch(true);
            moveToTaskSearch(taskFilter);
        }
    });
    simpleDisplayBtn.setIcon(FontAwesome.LIST_UL);
    simpleDisplayBtn.setDescription(AppContext.getMessage(TaskGroupI18nEnum.LIST_VIEW_TOOLTIP));

    Button chartDisplayBtn = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = -5707546605789537298L;

        @Override
        public void buttonClick(ClickEvent event) {
            displayGanttChartView();
        }
    });
    chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O);

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

    mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth().withSpacing(true);
    this.taskListsWidget = new TaskGroupDisplayWidget();

    MVerticalLayout leftColumn = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, false))
            .with(taskListsWidget);

    this.rightColumn = new MVerticalLayout().withWidth("300px")
            .withMargin(new MarginInfo(true, false, false, false));

    mainLayout.with(leftColumn, rightColumn).expand(leftColumn);

    FloatingComponent floatSidebar = FloatingComponent.floatThis(this.rightColumn);
    floatSidebar.setContainerId("main-body");

    implementTaskFilterButton();
    basicSearchView = new TaskSearchViewImpl();
    basicSearchView.getSearchHandlers().addSearchHandler(new SearchHandler<TaskSearchCriteria>() {
        @Override
        public void onSearch(TaskSearchCriteria criteria) {
            doSearch(criteria);
        }
    });
    basicSearchView.removeComponent(basicSearchView.getComponent(0));

    displayAdvancedView();
}

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

License:Open Source License

private void displayAdvancedView() {
    this.removeAllComponents();
    header.with(viewButtons).withAlign(viewButtons, Alignment.MIDDLE_RIGHT);
    this.with(header, mainLayout).withAlign(header, Alignment.TOP_RIGHT);
}

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

License:Open Source License

private void constructHeader() {
    CssLayout headerWrapper = new CssLayout();
    headerWrapper.setWidth("100%");
    headerWrapper.addStyleName("taskgroup-header");

    HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);//from  w w  w .java  2  s  .co m
    header.setWidth("100%");
    Label headerLbl = new Label("All Tasks");
    headerLbl.setStyleName("h2");
    header.addComponent(headerLbl);
    header.setComponentAlignment(headerLbl, Alignment.MIDDLE_LEFT);
    header.setExpandRatio(headerLbl, 1.0f);

    Button backToListBtn = new Button("Back to dashboard", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskListEvent.GotoTaskListScreen(this, null));
        }
    });
    backToListBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    header.addComponent(backToListBtn);
    header.setComponentAlignment(backToListBtn, Alignment.MIDDLE_RIGHT);

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

        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskListEvent.SaveReoderTaskList(event, changeSet));
        }
    });
    saveOrderBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    header.addComponent(saveOrderBtn);
    header.setComponentAlignment(saveOrderBtn, Alignment.MIDDLE_RIGHT);

    headerWrapper.addComponent(header);

    this.addComponent(headerWrapper);

    final DDVerticalLayout ddLayout = new DDVerticalLayout();
    ddLayout.addStyleName("taskgroup-reorder");
    ddLayout.setComponentVerticalDropRatio(0.3f);
    ddLayout.setDragMode(LayoutDragMode.CLONE);
    ddLayout.setDropHandler(new DropHandler() {
        private static final long serialVersionUID = 1L;

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

        @Override
        public void drop(DragAndDropEvent event) {
            LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();

            DDVerticalLayout.VerticalLayoutTargetDetails details = (DDVerticalLayout.VerticalLayoutTargetDetails) event
                    .getTargetDetails();

            TaskListComponent comp = (TaskListComponent) transferable.getComponent();

            int currentIndex = ddLayout.getComponentIndex(comp);
            int newIndex = details.getOverIndex();

            ddLayout.removeComponent(comp);

            if (currentIndex > newIndex && details.getDropLocation() == VerticalDropLocation.BOTTOM) {
                newIndex++;
            }

            SimpleTaskList dropTaskList = comp.getTaskList();
            dropTaskList.setGroupindex(newIndex);
            changeSet.add(dropTaskList);
            ddLayout.addComponent(comp, newIndex);

            // change affected task list items
            for (int i = 0; i < ddLayout.getComponentCount(); i++) {
                TaskListComponent affectedComp = (TaskListComponent) ddLayout.getComponent(i);
                SimpleTaskList affectedTaskList = affectedComp.getTaskList();
                affectedTaskList.setGroupindex(i);
                changeSet.add(affectedTaskList);
            }
        }
    });

    taskLists = new BeanList<ProjectTaskListService, TaskListSearchCriteria, SimpleTaskList>(null,
            ApplicationContextUtil.getSpringBean(ProjectTaskListService.class), TaskListRowDisplayHandler.class,
            ddLayout);
    this.addComponent(taskLists);
}

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);/*w  ww  . j a v  a  2s.c o 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.user.MyProjectListComponent.java

License:Open Source License

public MyProjectListComponent() {
    withSpacing(false).withMargin(false);
    this.addStyleName("myprojectlist");

    MHorizontalLayout header = new MHorizontalLayout().withSpacing(false)
            .withMargin(new MarginInfo(false, true, false, true)).withHeight("34px");
    header.addStyleName("panel-header");
    titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_ACTIVE_PROJECTS_TITLE, 0));

    final PopupButton projectsPopup = new PopupButton("");
    projectsPopup.addStyleName("popuplistindicator");

    final MVerticalLayout filterBtnLayout = new MVerticalLayout().withWidth("200px");

    ProjectService projectService = ApplicationContextUtil.getSpringBean(ProjectService.class);
    int allProjectCount = projectService.getTotalCount(getAllProjectsSearchCriteria());
    Button allProjectsBtn = new Button(
            AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ALL_PROJECTS, allProjectCount),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override//  www.  j av  a2  s.  c  o  m
                public void buttonClick(ClickEvent event) {
                    displayAllProjects();
                    projectsPopup.setPopupVisible(false);
                }
            });
    allProjectsBtn.setStyleName("link");
    filterBtnLayout.addComponent(allProjectsBtn);

    int activeProjectsCount = projectService.getTotalCount(getActiveProjectsSearchCriteria());
    Button activeProjectsBtn = new Button(
            AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECTS, activeProjectsCount),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    displayActiveProjects();
                    projectsPopup.setPopupVisible(false);
                }
            });
    activeProjectsBtn.setStyleName("link");
    filterBtnLayout.addComponent(activeProjectsBtn);

    int archiveProjectsCount = projectService.getTotalCount(getArchivedProjectsSearchCriteria());
    Button archiveProjectsBtn = new Button(
            AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECTS, archiveProjectsCount),
            new ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    displayArchiveProjects();
                    projectsPopup.setPopupVisible(false);
                }
            });
    archiveProjectsBtn.setStyleName("link");
    filterBtnLayout.addComponent(archiveProjectsBtn);
    projectsPopup.setContent(filterBtnLayout);

    header.with(titleLbl, projectsPopup).withAlign(titleLbl, Alignment.MIDDLE_LEFT)
            .withAlign(projectsPopup, Alignment.MIDDLE_RIGHT).expand(titleLbl);

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

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

License:Open Source License

public ProjectAssignmentsWidget() {
    withSpacing(false).withMargin(false);
    titleLbl = new Label(AppContext.getMessage(ProjectCommonI18nEnum.WIDGET_OPEN_ASSIGNMENTS_TITLE, 0));

    final CheckBox overdueSelection = new CheckBox("Overdue");
    overdueSelection.addValueChangeListener(new Property.ValueChangeListener() {
        @Override/*w w w .j  a  v  a 2 s. com*/
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            boolean isOverdueOption = overdueSelection.getValue();
            if (isOverdueOption) {
                searchCriteria.setDueDate(
                        new DateSearchField(DateSearchField.AND, DateTimeUtils.getCurrentDateWithoutMS()));
            } else {
                searchCriteria.setDueDate(null);
            }
            updateSearchResult();
        }
    });

    final CheckBox myItemsSelection = new CheckBox("My Items");
    myItemsSelection.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            boolean isMyItemsOption = myItemsSelection.getValue();
            if (isMyItemsOption) {
                searchCriteria.setAssignUser(new StringSearchField(AppContext.getUsername()));
            } else {
                searchCriteria.setAssignUser(null);
            }
            updateSearchResult();
        }
    });

    MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, true))
            .withHeight("34px").with(titleLbl, overdueSelection, myItemsSelection)
            .withAlign(titleLbl, Alignment.MIDDLE_LEFT).withAlign(overdueSelection, Alignment.MIDDLE_RIGHT)
            .withAlign(myItemsSelection, Alignment.MIDDLE_RIGHT).expand(titleLbl);
    header.addStyleName("panel-header");

    taskList = new DefaultBeanPagedList<>(ApplicationContextUtil.getSpringBean(ProjectGenericTaskService.class),
            new TaskRowDisplayHandler(), 10);
    this.with(header, taskList);
}