Example usage for com.vaadin.ui Button setEnabled

List of usage examples for com.vaadin.ui Button setEnabled

Introduction

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

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

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

License:Open Source License

public TaskDashboardViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));
    taskSearchPanel = new TaskSearchPanel();

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

    groupWrapLayout.addComponent(new Label("Sort"));
    final ComboBox sortCombo = new ValueComboBox(false,
            AppContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING),
            AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING));
    sortCombo.addValueChangeListener(new Property.ValueChangeListener() {
        @Override//from  ww w  . j a  v  a  2s.  co m
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            String sortValue = (String) sortCombo.getValue();
            if (AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) {
                sortDirection = SearchCriteria.ASC;
            } else {
                sortDirection = SearchCriteria.DESC;
            }
            queryAndDisplayTasks();
        }
    });
    sortDirection = SearchCriteria.DESC;
    groupWrapLayout.addComponent(sortCombo);

    groupWrapLayout.addComponent(new Label("Group by"));
    final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, GROUP_CREATED_DATE,
            PLAIN_LIST, GROUP_USER);
    groupCombo.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            groupByState = (String) groupCombo.getValue();
            queryAndDisplayTasks();
        }
    });
    groupByState = GROUP_DUE_DATE;
    groupWrapLayout.addComponent(groupCombo);

    taskSearchPanel.addHeaderRight(groupWrapLayout);

    Button printBtn = new Button("", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            UI.getCurrent().addWindow(new TaskCustomizeReportOutputWindow(new LazyValueInjector() {
                @Override
                protected Object doEval() {
                    return baseCriteria;
                }
            }));
        }
    });
    printBtn.setIcon(FontAwesome.PRINT);
    printBtn.addStyleName(UIConstants.BUTTON_OPTION);
    printBtn.setDescription(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    groupWrapLayout.addComponent(printBtn);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
                SimpleTask newTask = new SimpleTask();
                newTask.setProjectid(CurrentProjectVariables.getProjectId());
                newTask.setSaccountid(AppContext.getAccountId());
                newTask.setLogby(AppContext.getUsername());
                UI.getCurrent().addWindow(new TaskAddWindow(newTask));
            }
        }
    });
    newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
    newTaskBtn.setIcon(FontAwesome.PLUS);
    newTaskBtn.setStyleName(UIConstants.BUTTON_ACTION);
    groupWrapLayout.addComponent(newTaskBtn);

    Button advanceDisplayBtn = new Button("List");
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Advance View");

    Button kanbanBtn = new Button("Kanban", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent clickEvent) {
            displayKanbanView();
        }
    });
    kanbanBtn.setWidth("100px");
    kanbanBtn.setDescription("Kanban View");
    kanbanBtn.setIcon(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(taskSearchPanel, mainLayout);
}

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 va  2  s  .  c  o  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.TaskGroupNoItemView.java

License:Open Source License

public TaskGroupNoItemView() {
    this.setMargin(new MarginInfo(true, false, false, false));
    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName("taskgroup-noitem");
    layout.setSpacing(true);//from www  . j  a  v  a  2  s  .c om
    layout.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    layout.setMargin(true);

    Image image = new Image(null, MyCollabResource.newResource("icons/48/project/tasklist.png"));
    layout.addComponent(image);

    Label title = new Label(AppContext.getMessage(TaskGroupI18nEnum.NO_ITEM_VIEW_TITLE));
    title.addStyleName("h2");
    title.setWidthUndefined();
    layout.addComponent(title);

    Label body = new Label(AppContext.getMessage(TaskGroupI18nEnum.NO_ITEM_VIEW_HINT));
    body.setWidthUndefined();
    layout.addComponent(body);

    Button createTaskGroupBtn = 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(null);
                    UI.getCurrent().addWindow(taskListWindow);
                }
            });
    createTaskGroupBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));

    HorizontalLayout links = new HorizontalLayout();

    links.addComponent(createTaskGroupBtn);
    createTaskGroupBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    links.setSpacing(true);

    layout.addComponent(links);
    this.addComponent(layout);
    this.setComponentAlignment(layout, Alignment.TOP_CENTER);
}

From source file:com.esofthead.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);

    toggleShowColumsBtn = new Button("");
    toggleShowColumsBtn.addClickListener(new Button.ClickListener() {
        @Override/*from  w  w  w . ja va 2s  .  c  om*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            displayHiddenColumns = !displayHiddenColumns;
            reload();
            toggleShowButton();
        }
    });
    toggleShowColumsBtn.addStyleName(UIConstants.BUTTON_LINK);
    groupWrapLayout.addComponent(toggleShowColumsBtn);
    toggleShowButton();

    Button addNewColumnBtn = new Button(AppContext.getMessage(TaskI18nEnum.ACTION_NEW_COLUMN),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    UI.getCurrent().addWindow(new AddNewColumnWindow(TaskKanbanBoardViewImpl.this,
                            ProjectTypeConstants.TASK, "status"));
                }
            });
    addNewColumnBtn.setIcon(FontAwesome.PLUS);
    addNewColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    addNewColumnBtn.setStyleName(UIConstants.BUTTON_ACTION);
    groupWrapLayout.addComponent(addNewColumnBtn);

    Button deleteColumnBtn = new Button("Delete columns", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent()
                    .addWindow(new DeleteColumnWindow(TaskKanbanBoardViewImpl.this, ProjectTypeConstants.TASK));
        }
    });
    deleteColumnBtn.setIcon(FontAwesome.TRASH_O);
    deleteColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    deleteColumnBtn.setStyleName(UIConstants.BUTTON_DANGER);

    Button advanceDisplayBtn = new Button("List", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskEvent.GotoDashboard(TaskKanbanBoardViewImpl.this, null));
        }
    });
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Advance View");

    Button kanbanBtn = new Button("Kanban");
    kanbanBtn.setWidth("100px");
    kanbanBtn.setDescription("Kanban View");
    kanbanBtn.setIcon(FontAwesome.TH);

    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 HashedMap(2);
                    map.put("id", blockItem.optionVal.getId());
                    map.put("index", i);
                    indexMap.add(map);
                }
                if (indexMap.size() > 0) {
                    optionValService.massUpdateOptionIndexes(indexMap, AppContext.getAccountId());
                }
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return new Not(VerticalLocationIs.MIDDLE);
        }
    });
    this.setWidth("100%");
    this.with(searchPanel, kanbanLayout).expand(kanbanLayout);
}

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

License:Open Source License

public TaskKanbanviewImpl() {
    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);

    Button addNewColumnBtn = new Button("New column", new Button.ClickListener() {
        @Override/*from  ww w.ja v a  2 s.c  om*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            UI.getCurrent()
                    .addWindow(new AddNewColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK));
        }
    });
    addNewColumnBtn.setIcon(FontAwesome.PLUS);
    addNewColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    addNewColumnBtn.setStyleName(UIConstants.BUTTON_ACTION);
    groupWrapLayout.addComponent(addNewColumnBtn);

    Button deleteColumBtn = new Button("Delete columns", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent()
                    .addWindow(new DeleteColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK));
        }
    });
    deleteColumBtn.setIcon(FontAwesome.TRASH_O);
    deleteColumBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    deleteColumBtn.setStyleName(UIConstants.BUTTON_DANGER);

    Button advanceDisplayBtn = new Button("List", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskEvent.GotoDashboard(TaskKanbanviewImpl.this, null));
        }
    });
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Advance View");

    Button kanbanBtn = new Button("Kanban");
    kanbanBtn.setWidth("100px");
    kanbanBtn.setDescription("Kanban View");
    kanbanBtn.setIcon(FontAwesome.TH);

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.setDefaultButton(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 HashedMap(2);
                    map.put("id", blockItem.optionVal.getId());
                    map.put("index", i);
                    indexMap.add(map);
                }
                if (indexMap.size() > 0) {
                    optionValService.massUpdateOptionIndexes(indexMap, AppContext.getAccountId());
                }
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return new Not(VerticalLocationIs.MIDDLE);
        }
    });
    this.setWidth("100%");
    this.with(searchPanel, kanbanLayout).expand(kanbanLayout);
}

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

License:Open Source License

public TaskSearchTableDisplay(TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(ProjectTaskService.class), SimpleTask.class, requiredColumn,
            displayColumns);//from ww w  .  j  ava2  s.c  o m

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId);

            CssLayout taskName = new CssLayout();

            String taskname = "[%s-%s] %s";
            taskname = String.format(taskname, CurrentProjectVariables.getProject().getShortname(),
                    task.getTaskkey(), task.getTaskname());
            LabelLink b = new LabelLink(taskname, ProjectLinkBuilder
                    .generateTaskPreviewFullLink(task.getTaskkey(), task.getProjectShortname()));
            b.setDescription(ProjectTooltipGenerator.generateToolTipTask(AppContext.getUserLocale(), task,
                    AppContext.getSiteUrl(), AppContext.getTimezone()));

            if (StringUtils.isNotBlank(task.getPriority())) {
                b.setIconLink(ProjectResources.getIconResourceLink12ByTaskPriority(task.getPriority()));

            }

            if (task.getPercentagecomplete() != null && 100d == task.getPercentagecomplete()) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else {
                if ("Pending".equals(task.getStatus())) {
                    b.addStyleName(UIConstants.LINK_PENDING);
                } else if ((task.getEnddate() != null
                        && (task.getEnddate().before(new GregorianCalendar().getTime())))
                        || (task.getActualenddate() != null
                                && (task.getActualenddate().before(new GregorianCalendar().getTime())))
                        || (task.getDeadline() != null
                                && (task.getDeadline().before(new GregorianCalendar().getTime())))) {
                    b.addStyleName(UIConstants.LINK_OVERDUE);
                }
            }

            taskName.addComponent(b);
            taskName.setWidth("100%");
            taskName.setHeightUndefined();
            return taskName;

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId);
            Double percomp = (task.getPercentagecomplete() == null) ? new Double(0)
                    : task.getPercentagecomplete();
            ProgressPercentageIndicator progress = new ProgressPercentageIndicator(percomp);
            progress.setWidth("100px");
            return progress;
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(task.getStartdate()));

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(task.getDeadline()));

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId);
            PopupButton taskSettingPopupBtn = new PopupButton();
            VerticalLayout filterBtnLayout = new VerticalLayout();
            filterBtnLayout.setMargin(true);
            filterBtnLayout.setSpacing(true);
            filterBtnLayout.setWidth("100px");

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

                        @Override
                        public void buttonClick(ClickEvent event) {
                            EventBusFactory.getInstance()
                                    .post(new TaskEvent.GotoEdit(TaskSearchTableDisplay.this, task));
                        }
                    });
            editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
            editButton.setStyleName("link");
            filterBtnLayout.addComponent(editButton);

            if ((task.getPercentagecomplete() != null && task.getPercentagecomplete() != 100)
                    || task.getPercentagecomplete() == null) {
                Button closeBtn = new Button("Close", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        task.setStatus("Closed");
                        task.setPercentagecomplete(100d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateWithSession(task, AppContext.getUsername());

                        fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this, task, "closeTask"));
                    }
                });
                closeBtn.setStyleName("link");
                closeBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(closeBtn);
            } else {
                Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        task.setStatus("Open");
                        task.setPercentagecomplete(0d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateWithSession(task, AppContext.getUsername());
                        fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this, task, "reopenTask"));
                    }
                });
                reOpenBtn.setStyleName("link");
                reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(reOpenBtn);
            }

            if (!"Pending".equals(task.getStatus())) {
                if (!"Closed".equals(task.getStatus())) {
                    Button pendingBtn = new Button("Pending", new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            task.setStatus("Pending");
                            task.setPercentagecomplete(0d);

                            ProjectTaskService projectTaskService = ApplicationContextUtil
                                    .getSpringBean(ProjectTaskService.class);
                            projectTaskService.updateWithSession(task, AppContext.getUsername());
                            fireTableEvent(
                                    new TableClickEvent(TaskSearchTableDisplay.this, task, "pendingTask"));
                        }
                    });
                    pendingBtn.setStyleName("link");
                    pendingBtn.setEnabled(
                            CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                    filterBtnLayout.addComponent(pendingBtn);
                }
            } else {
                Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        task.setStatus("Open");
                        task.setPercentagecomplete(0d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateWithSession(task, AppContext.getUsername());

                        fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this, task, "reopenTask"));
                    }
                });
                reOpenBtn.setStyleName("link");
                reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(reOpenBtn);
            }

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

                        @Override
                        public void buttonClick(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()) {
                                                ProjectTaskService projectTaskService = ApplicationContextUtil
                                                        .getSpringBean(ProjectTaskService.class);
                                                projectTaskService.removeWithSession(task.getId(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                fireTableEvent(new TableClickEvent(TaskSearchTableDisplay.this,
                                                        task, "deleteTask"));
                                            }
                                        }
                                    });
                        }
                    });
            deleteBtn.setStyleName("link");
            deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
            filterBtnLayout.addComponent(deleteBtn);

            taskSettingPopupBtn.setIcon(MyCollabResource.newResource("icons/16/item_settings.png"));
            taskSettingPopupBtn.setStyleName("link");
            taskSettingPopupBtn.setContent(filterBtnLayout);
            return taskSettingPopupBtn;
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskSearchTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(task.getAssignuser(), task.getAssignUserAvatarId(),
                    task.getAssignUserFullName());

        }
    });
    this.setWidth("100%");
}

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

License:Open Source License

public TaskTableDisplay(TableViewField requiredColumn, List<TableViewField> displayColumns, int displayNums) {
    super(ApplicationContextUtil.getSpringBean(ProjectTaskService.class), SimpleTask.class, requiredColumn,
            displayColumns);//from  w  w  w.  java2s.  c o  m
    this.displayNumItems = displayNums;

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);

            CssLayout taskName = new CssLayout();

            String taskname = "[%s-%s] %s";
            taskname = String.format(taskname, CurrentProjectVariables.getProject().getShortname(),
                    task.getTaskkey(), task.getTaskname());

            LabelLink b = new LabelLink(taskname, ProjectLinkBuilder
                    .generateTaskPreviewFullLink(task.getTaskkey(), task.getProjectShortname()));
            b.setDescription(ProjectTooltipGenerator.generateToolTipTask(AppContext.getUserLocale(), task,
                    AppContext.getSiteUrl(), AppContext.getTimezone()));

            if (StringUtils.isNotBlank(task.getPriority())) {
                b.setIconLink(ProjectResources.getIconResourceLink12ByTaskPriority(task.getPriority()));

            }

            if (task.isCompleted()) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else if (task.isPending()) {
                b.addStyleName(UIConstants.LINK_PENDING);
            } else if (task.isOverdue()) {
                b.addStyleName(UIConstants.LINK_OVERDUE);
            }

            taskName.addComponent(b);
            taskName.setWidth("100%");
            taskName.setHeightUndefined();
            return taskName;

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            Double percomp = (task.getPercentagecomplete() == null) ? new Double(0)
                    : task.getPercentagecomplete();
            ProgressPercentageIndicator progress = new ProgressPercentageIndicator(percomp);
            progress.setWidth("100px");
            return progress;
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(task.getStartdate()));

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(task.getDeadline()));

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            PopupButton taskSettingPopupBtn = new PopupButton();
            taskSettingPopupBtn.setIcon(MyCollabResource.newResource("icons/16/item_settings.png"));
            taskSettingPopupBtn.setStyleName("link");
            taskSettingPopupBtn.addStyleName("noDefaultIcon");

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

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

                        @Override
                        public void buttonClick(ClickEvent event) {
                            EventBusFactory.getInstance()
                                    .post(new TaskEvent.GotoEdit(TaskTableDisplay.this, task));
                        }
                    });
            editButton.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
            editButton.setStyleName("link");
            filterBtnLayout.addComponent(editButton);

            if ((task.getPercentagecomplete() != null && task.getPercentagecomplete() != 100)
                    || task.getPercentagecomplete() == null) {
                Button closeBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLOSE),
                        new Button.ClickListener() {
                            private static final long serialVersionUID = 1L;

                            @Override
                            public void buttonClick(Button.ClickEvent event) {
                                task.setStatus(StatusI18nEnum.Closed.name());
                                task.setPercentagecomplete(100d);

                                ProjectTaskService projectTaskService = ApplicationContextUtil
                                        .getSpringBean(ProjectTaskService.class);
                                projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());

                                fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "closeTask"));
                            }
                        });
                closeBtn.setStyleName("link");
                closeBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(closeBtn);
            } else {
                Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        task.setStatus(StatusI18nEnum.Open.name());
                        task.setPercentagecomplete(0d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());
                        fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "reopenTask"));
                    }
                });
                reOpenBtn.setStyleName("link");
                reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(reOpenBtn);
            }

            if (!"Pending".equals(task.getStatus())) {
                if (!"Closed".equals(task.getStatus())) {
                    Button pendingBtn = new Button("Pending", new Button.ClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void buttonClick(ClickEvent event) {
                            task.setStatus("Pending");
                            task.setPercentagecomplete(0d);

                            ProjectTaskService projectTaskService = ApplicationContextUtil
                                    .getSpringBean(ProjectTaskService.class);
                            projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());
                            fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "pendingTask"));
                        }
                    });
                    pendingBtn.setStyleName("link");
                    pendingBtn.setEnabled(
                            CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                    filterBtnLayout.addComponent(pendingBtn);
                }
            } else {
                Button reOpenBtn = new Button("ReOpen", new Button.ClickListener() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        task.setStatus("Open");
                        task.setPercentagecomplete(0d);

                        ProjectTaskService projectTaskService = ApplicationContextUtil
                                .getSpringBean(ProjectTaskService.class);
                        projectTaskService.updateSelectiveWithSession(task, AppContext.getUsername());

                        fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task, "reopenTask"));
                    }
                });
                reOpenBtn.setStyleName("link");
                reOpenBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
                filterBtnLayout.addComponent(reOpenBtn);
            }

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

                        @Override
                        public void buttonClick(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()) {
                                                ProjectTaskService projectTaskService = ApplicationContextUtil
                                                        .getSpringBean(ProjectTaskService.class);
                                                projectTaskService.removeWithSession(task.getId(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                fireTableEvent(new TableClickEvent(TaskTableDisplay.this, task,
                                                        "deleteTask"));
                                            }
                                        }
                                    });
                        }
                    });
            deleteBtn.setStyleName("link");
            deleteBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
            filterBtnLayout.addComponent(deleteBtn);

            taskSettingPopupBtn.setContent(filterBtnLayout);
            return taskSettingPopupBtn;
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleTask task = TaskTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(task.getAssignuser(), task.getAssignUserAvatarId(),
                    task.getAssignUserFullName());

        }
    });
    this.setWidth("100%");
}

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

License:Open Source License

@Override
protected CssLayout createPageControls() {
    this.controlBarWrapper = new CssLayout();
    this.controlBarWrapper.setWidth("100%");
    this.controlBarWrapper.setStyleName("page-controls");
    ButtonGroup controlBtns = new ButtonGroup();
    controlBtns.setStyleName(UIConstants.THEME_GREEN_LINK);
    Button prevBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NAV_NEWER),
            new Button.ClickListener() {
                private static final long serialVersionUID = -94021599166105307L;

                @Override//ww w  .j  a  va  2  s. co m
                public void buttonClick(ClickEvent event) {
                    ProjectActivityStreamPagedList.this
                            .pageChange(ProjectActivityStreamPagedList.this.currentPage - 1);
                }
            });
    if (currentPage == 1) {
        prevBtn.setEnabled(false);
    }
    prevBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    prevBtn.setWidth("64px");

    Button nextBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NAV_OLDER),
            new Button.ClickListener() {
                private static final long serialVersionUID = 3095522916508256018L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ProjectActivityStreamPagedList.this
                            .pageChange(ProjectActivityStreamPagedList.this.currentPage + 1);
                }
            });
    if (currentPage == totalPage) {
        nextBtn.setEnabled(false);
    }
    nextBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    nextBtn.setWidth("64px");

    controlBtns.addButton(prevBtn);
    controlBtns.addButton(nextBtn);

    this.controlBarWrapper.addComponent(controlBtns);

    return this.controlBarWrapper;
}

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

License:Open Source License

public ProjectInfoComponent(final SimpleProject project) {
    this.withMargin(true).withStyleName("project-info").withFullWidth();
    Component projectIcon = ProjectAssetsUtil.buildProjectLogo(project.getShortname(), project.getId(),
            project.getAvatarid(), 64);/*from  w  w w  .  j  ava  2s  .  co  m*/
    this.with(projectIcon).withAlign(projectIcon, Alignment.TOP_LEFT);
    ELabel headerLbl = ELabel.h2(project.getName());
    headerLbl.setDescription(ProjectTooltipGenerator.generateToolTipProject(AppContext.getUserLocale(),
            AppContext.getDateFormat(), project, AppContext.getSiteUrl(), AppContext.getUserTimeZone()));
    headerLbl.addStyleName(UIConstants.TEXT_ELLIPSIS);
    MVerticalLayout headerLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true));

    MHorizontalLayout footer = new MHorizontalLayout();
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    footer.addStyleName(UIConstants.META_INFO);
    footer.addStyleName(UIConstants.FLEX_DISPLAY);

    ELabel createdTimeLbl = new ELabel(
            FontAwesome.CLOCK_O.getHtml() + " " + AppContext.formatPrettyTime(project.getCreatedtime()),
            ContentMode.HTML).withDescription(AppContext.getMessage(GenericI18Enum.FORM_CREATED_TIME))
                    .withStyleName(ValoTheme.LABEL_SMALL).withWidthUndefined();
    footer.addComponents(createdTimeLbl);

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

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

    if (project.getNumActiveMembers() > 0) {
        ELabel activeMembersLbl = new ELabel(FontAwesome.USERS.getHtml() + " " + project.getNumActiveMembers(),
                ContentMode.HTML).withDescription("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.getInstance()
                    .getEntityLogoPath(AppContext.getAccountId(), project.getClientAvatarId(), 16));
            clientDiv.appendChild(clientImg).appendChild(DivLessFormatter.EMPTY_SPACE());
        }
        clientDiv.appendChild(new A(ProjectLinkBuilder.generateClientPreviewFullLink(project.getAccountid()))
                .appendText(project.getClientName()));
        ELabel accountBtn = new ELabel(clientDiv.write(), ContentMode.HTML)
                .withStyleName(UIConstants.BUTTON_BLOCK).withWidthUndefined();
        footer.addComponents(accountBtn);
    }

    if (!SiteConfiguration.isCommunityEdition()) {
        Button tagBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TAG),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoTagListView(this, null));
                    }
                });
        tagBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        tagBtn.addStyleName(UIConstants.BUTTON_ACTION);
        tagBtn.setDescription("Tag management");
        tagBtn.setIcon(FontAwesome.TAGS);
        footer.addComponents(tagBtn);

        Button favoriteBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_FAVORITES),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoFavoriteView(this, null));
                    }
                });
        favoriteBtn.setCaptionAsHtml(true);
        favoriteBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        favoriteBtn.addStyleName(UIConstants.BUTTON_ACTION);
        favoriteBtn.setIcon(FontAwesome.STAR);
        favoriteBtn.setDescription("Your favorite list");
        footer.addComponents(favoriteBtn);

        Button eventBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_CALENDAR),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoCalendarView(this));
                    }
                });
        eventBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        eventBtn.addStyleName(UIConstants.BUTTON_ACTION);
        eventBtn.setIcon(FontAwesome.CALENDAR);
        eventBtn.setDescription("Calendar");
        footer.addComponents(eventBtn);

        Button ganttChartBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_GANTT_CHART),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent clickEvent) {
                        EventBusFactory.getInstance().post(new ProjectEvent.GotoGanttChart(this, null));
                    }
                });
        ganttChartBtn.addStyleName(UIConstants.BUTTON_SMALL_PADDING);
        ganttChartBtn.addStyleName(UIConstants.BUTTON_ACTION);
        ganttChartBtn.setIcon(FontAwesome.BAR_CHART_O);
        ganttChartBtn.setDescription("Gantt chart");
        footer.addComponents(ganttChartBtn);
    }

    headerLayout.with(headerLbl, footer);

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

    if (project.isProjectArchived()) {
        Button activeProjectBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ACTIVE_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class);
                        project.setProjectstatus(OptionI18nEnum.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.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(UIConstants.BOX);
        controlsBtn.setIcon(FontAwesome.ELLIPSIS_H);

        OptionPopupContent popupButtonsControl = new OptionPopupContent();

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

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

        Button createBugBtn = new Button(AppContext.getMessage(BugI18nEnum.NEW), new Button.ClickListener() {
            @Override
            public void buttonClick(Button.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));
        popupButtonsControl.addOption(createBugBtn);

        Button createComponentBtn = new Button(AppContext.getMessage(ComponentI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new BugComponentEvent.GotoAdd(this, null));
                    }
                });
        createComponentBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.COMPONENTS));
        createComponentBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_COMPONENT));
        popupButtonsControl.addOption(createComponentBtn);

        Button createVersionBtn = new Button(AppContext.getMessage(VersionI18nEnum.NEW),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new BugVersionEvent.GotoAdd(this, null));
                    }
                });
        createVersionBtn
                .setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.VERSIONS));
        createVersionBtn.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG_VERSION));
        popupButtonsControl.addOption(createVersionBtn);

        if (!SiteConfiguration.isCommunityEdition()) {
            Button createRiskBtn = new Button(AppContext.getMessage(RiskI18nEnum.NEW),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.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));
            popupButtonsControl.addOption(createRiskBtn);
        }

        popupButtonsControl.addSeparator();
        Button inviteMemberBtn = new Button(AppContext.getMessage(ProjectMemberI18nEnum.BUTTON_NEW_INVITEES),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectMemberEvent.GotoInviteMembers(this, null));
                    }
                });
        inviteMemberBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
        inviteMemberBtn.setIcon(FontAwesome.SEND);
        popupButtonsControl.addOption(inviteMemberBtn);

        Button settingBtn = new Button(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_SETTINGS),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance().post(new ProjectNotificationEvent.GotoList(this, null));
                    }
                });
        settingBtn.setIcon(FontAwesome.COG);
        popupButtonsControl.addOption(settingBtn);

        popupButtonsControl.addSeparator();

        final Button markProjectTemplateBtn = new Button();
        markProjectTemplateBtn.addClickListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                Boolean isTemplate = !MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
                project.setIstemplate(isTemplate);
                ProjectService prjService = AppContextUtil.getSpringBean(ProjectService.class);
                prjService.updateWithSession(project, AppContext.getUsername());
                if (project.getIstemplate()) {
                    markProjectTemplateBtn
                            .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
                } else {
                    markProjectTemplateBtn
                            .setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
                }
            }
        });
        markProjectTemplateBtn.setIcon(FontAwesome.STICKY_NOTE);
        Boolean isTemplate = MoreObjects.firstNonNull(project.getIstemplate(), Boolean.FALSE);
        if (isTemplate) {
            markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_UNMARK_TEMPLATE));
        } else {
            markProjectTemplateBtn.setCaption(AppContext.getMessage(ProjectI18nEnum.ACTION_MARK_TEMPLATE));
        }
        markProjectTemplateBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.CREATE_NEW_PROJECT));
        popupButtonsControl.addOption(markProjectTemplateBtn);

        Button editProjectBtn = new Button(AppContext.getMessage(ProjectI18nEnum.EDIT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        EventBusFactory.getInstance()
                                .post(new ProjectEvent.GotoEdit(ProjectInfoComponent.this, project));
                    }
                });
        editProjectBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PROJECT));
        editProjectBtn.setIcon(FontAwesome.EDIT);
        popupButtonsControl.addOption(editProjectBtn);

        Button archiveProjectBtn = new Button(
                AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_ARCHIVE_PROJECT),
                new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        controlsBtn.setPopupVisible(false);
                        ConfirmDialogExt.show(UI.getCurrent(),
                                AppContext.getMessage(GenericI18Enum.WINDOW_WARNING_TITLE,
                                        AppContext.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 = AppContextUtil
                                                    .getSpringBean(ProjectService.class);
                                            project.setProjectstatus(
                                                    OptionI18nEnum.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));
                                        }
                                    }
                                });
                    }
                });
        archiveProjectBtn
                .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
        archiveProjectBtn.setIcon(FontAwesome.ARCHIVE);
        popupButtonsControl.addOption(archiveProjectBtn);

        if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT)) {
            popupButtonsControl.addSeparator();
            Button deleteProjectBtn = new Button(
                    AppContext.getMessage(ProjectCommonI18nEnum.BUTTON_DELETE_PROJECT),
                    new Button.ClickListener() {
                        @Override
                        public void buttonClick(Button.ClickEvent event) {
                            controlsBtn.setPopupVisible(false);
                            ConfirmDialogExt.show(UI.getCurrent(),
                                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE,
                                            AppContext.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 = AppContextUtil
                                                        .getSpringBean(ProjectService.class);
                                                projectService.removeWithSession(
                                                        CurrentProjectVariables.getProject(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                EventBusFactory.getInstance()
                                                        .post(new ShellEvent.GotoProjectModule(this, null));
                                            }
                                        }
                                    });
                        }
                    });
            deleteProjectBtn
                    .setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PROJECT));
            deleteProjectBtn.setIcon(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.esofthead.mycollab.module.user.accountsettings.customize.view.GeneralSettingViewImpl.java

License:Open Source License

private void buildLogoPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(true);
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    Label logoDesc = new Label(AppContext.getMessage(AdminI18nEnum.OPT_LOGO_FORMAT_DESCRIPTION));
    leftPanel.with(logoDesc).withWidth("250px");

    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    CustomLayout previewLayout = CustomLayoutExt.createLayout("topNavigation");
    previewLayout.setStyleName("example-block");
    previewLayout.setHeight("40px");
    previewLayout.setWidth("520px");

    Button currentLogo = AccountAssetsResolver.createAccountLogoImageComponent(billingAccount.getLogopath(),
            150);//from   w ww.  j av  a2s.c o  m
    previewLayout.addComponent(currentLogo, "mainLogo");
    final ServiceMenu serviceMenu = new ServiceMenu();

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

        @Override
        public void buttonClick(final Button.ClickEvent event) {
            Iterator<Component> iterator = serviceMenu.iterator();

            while (iterator.hasNext()) {
                Component comp = iterator.next();
                if (comp != event.getButton()) {
                    comp.removeStyleName("selected");
                }
            }
            event.getButton().addStyleName("selected");
        }
    };

    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener);
    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS,
            clickListener);
    serviceMenu.addService(AppContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), VaadinIcons.SUITCASE,
            clickListener);
    serviceMenu.selectService(0);

    previewLayout.addComponent(serviceMenu, "serviceMenu");

    MHorizontalLayout buttonControls = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    final UploadField logoUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplay() {
            byte[] imageData = (byte[]) this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(
                            AppContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                UI.getCurrent().addWindow(new LogoEditWindow(imageData));
            } else {
                throw new UserInvalidInputException(
                        AppContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    logoUploadField.setButtonCaption(AppContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    logoUploadField.addStyleName("upload-field");
    logoUploadField.setSizeUndefined();
    logoUploadField.setFieldType(UploadField.FieldType.BYTE_ARRAY);
    logoUploadField.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    Button resetButton = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent clickEvent) {
                    BillingAccountService billingAccountService = AppContextUtil
                            .getSpringBean(BillingAccountService.class);
                    billingAccount.setLogopath(null);
                    billingAccountService.updateWithSession(billingAccount, AppContext.getUsername());
                    Page.getCurrent().getJavaScript().execute("window.location.reload();");
                }
            });
    resetButton.setEnabled(AppContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));
    resetButton.setStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(logoUploadField, resetButton);
    rightPanel.with(previewLayout, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Logo", layout);
    this.with(formContainer);
}