Example usage for com.vaadin.ui HorizontalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.esofthead.mycollab.module.project.view.bug.components.UnresolvedBugsByPriorityWidget.java

License:Open Source License

public void setSearchCriteria(final BugSearchCriteria searchCriteria) {
    this.bugSearchCriteria = searchCriteria;
    this.bodyContent.removeAllComponents();
    final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
    final int totalCount = bugService.getTotalCount(searchCriteria);
    final List<GroupItem> groupItems = bugService.getPrioritySummary(searchCriteria);
    final BugPriorityClickListener listener = new BugPriorityClickListener();

    if (!groupItems.isEmpty()) {
        for (final BugPriority priority : OptionI18nEnum.bug_priorities) {
            boolean isFound = false;
            for (final GroupItem item : groupItems) {
                if (priority.name().equals(item.getGroupid())) {
                    isFound = true;//  www. j  a va2 s .  c o m
                    final HorizontalLayout priorityLayout = new HorizontalLayout();
                    priorityLayout.setSpacing(true);
                    priorityLayout.setWidth("100%");
                    final ButtonI18nComp priorityLink = new ButtonI18nComp(priority.name(), priority, listener);
                    priorityLink.setWidth("110px");
                    priorityLink.setStyleName("link");

                    priorityLayout.addComponent(priorityLink);
                    final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount,
                            totalCount - item.getValue(), false);
                    indicator.setWidth("100%");
                    priorityLayout.addComponent(indicator);
                    priorityLayout.setExpandRatio(indicator, 1.0f);

                    this.bodyContent.addComponent(priorityLayout);
                    continue;
                }
            }

            if (!isFound) {
                final HorizontalLayout priorityLayout = new HorizontalLayout();
                priorityLayout.setSpacing(true);
                priorityLayout.setWidth("100%");
                final ButtonI18nComp priorityLink = new ButtonI18nComp(priority.name(), priority, listener);
                priorityLink.setWidth("110px");
                priorityLink.setStyleName("link");
                priorityLayout.addComponent(priorityLink);
                final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount, false);
                indicator.setWidth("100%");
                priorityLayout.addComponent(indicator);
                priorityLayout.setExpandRatio(indicator, 1.0f);

                this.bodyContent.addComponent(priorityLayout);
            }
        }

    }
}

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

License:Open Source License

public void setSearchCriteria(final BugSearchCriteria searchCriteria) {
    this.bugSearchCriteria = searchCriteria;
    this.bodyContent.removeAllComponents();
    final BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
    final int totalCount = bugService.getTotalCount(searchCriteria);
    final List<GroupItem> groupItems = bugService.getPrioritySummary(searchCriteria);
    final BugPriorityClickListener listener = new BugPriorityClickListener();

    if (!groupItems.isEmpty()) {
        for (final BugPriority priority : OptionI18nEnum.bug_priorities) {
            boolean isFound = false;
            for (final GroupItem item : groupItems) {
                if (priority.name().equals(item.getGroupid())) {
                    isFound = true;/*w w  w .  j  a  v  a  2  s . c om*/
                    final HorizontalLayout priorityLayout = new HorizontalLayout();
                    priorityLayout.setSpacing(true);
                    priorityLayout.setWidth("100%");
                    final ButtonI18nComp userLbl = new ButtonI18nComp(priority.name(), priority, listener);
                    final Resource iconPriority = new ExternalResource(
                            ProjectResources.getIconResourceLink12ByBugPriority(priority.name()));
                    userLbl.setIcon(iconPriority);
                    userLbl.setWidth("110px");
                    userLbl.setStyleName("link");

                    priorityLayout.addComponent(userLbl);
                    final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount,
                            totalCount - item.getValue(), false);
                    indicator.setWidth("100%");
                    priorityLayout.addComponent(indicator);
                    priorityLayout.setExpandRatio(indicator, 1.0f);

                    this.bodyContent.addComponent(priorityLayout);
                    continue;
                }
            }

            if (!isFound) {
                final HorizontalLayout priorityLayout = new HorizontalLayout();
                priorityLayout.setSpacing(true);
                priorityLayout.setWidth("100%");
                final Button userLbl = new ButtonI18nComp(priority.name(), priority, listener);
                final Resource iconPriority = new ExternalResource(
                        ProjectResources.getIconResourceLink12ByBugPriority(priority.name()));
                userLbl.setIcon(iconPriority);
                userLbl.setWidth("110px");
                userLbl.setStyleName("link");
                priorityLayout.addComponent(userLbl);
                final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount, totalCount, false);
                indicator.setWidth("100%");
                priorityLayout.addComponent(indicator);
                priorityLayout.setExpandRatio(indicator, 1.0f);

                this.bodyContent.addComponent(priorityLayout);
            }
        }

    }
}

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

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);/*from   www . j  a v a 2  s  .  co m*/
    layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);

    this.selectOptionButton = new SelectionOptionButton(this.tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlersContainer();

    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.VERSIONS)) {
        tableActionControls.addActionItem(MassItemActionHandler.DELETE_ACTION, FontAwesome.TRASH_O, "delete",
                AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    }

    tableActionControls.addActionItem(MassItemActionHandler.MAIL_ACTION, FontAwesome.ENVELOPE_O, "mail",
            AppContext.getMessage(GenericI18Enum.BUTTON_MAIL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_PDF_ACTION, FontAwesome.FILE_PDF_O,
            "export", "export.pdf", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_EXCEL_ACTION,
            FontAwesome.FILE_EXCEL_O, "export", "export.xlsx",
            AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_CSV_ACTION, FontAwesome.FILE_TEXT_O,
            "export", "export.csv", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV));

    layout.addComponent(this.tableActionControls);
    layout.addComponent(this.selectedItemsNumberLabel);
    layout.setComponentAlignment(this.selectedItemsNumberLabel, Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

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

License:Open Source License

private void constructHeader() {
    final HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);//from   w  w  w .j a va 2s.c  o  m
    header.setWidth("100%");
    final Label taskGroupSelection = new Label(AppContext.getMessage(MilestoneI18nEnum.TAB_RELATED_BUGS));
    taskGroupSelection.addStyleName("h2");
    taskGroupSelection.addStyleName(UIConstants.THEME_NO_BORDER);
    header.addComponent(taskGroupSelection);
    header.setExpandRatio(taskGroupSelection, 1.0f);
    header.setComponentAlignment(taskGroupSelection, Alignment.MIDDLE_LEFT);

    this.viewGroup = new ToggleButtonGroup();

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

        @Override
        public void buttonClick(final ClickEvent event) {
            MilestoneBugListComp.this.displaySimpleView();
        }
    });
    simpleDisplay.setIcon(MyCollabResource.newResource("icons/16/project/list_display.png"));

    this.viewGroup.addButton(simpleDisplay);

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

        @Override
        public void buttonClick(final ClickEvent event) {
            MilestoneBugListComp.this.displayAdvancedView();
        }
    });
    advanceDisplay.setIcon(MyCollabResource.newResource("icons/16/project/bug_advanced_display.png"));
    this.viewGroup.addButton(advanceDisplay);
    header.addComponent(this.viewGroup);
    header.setComponentAlignment(this.viewGroup, Alignment.MIDDLE_RIGHT);
    this.addComponent(header);
}

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

License:Open Source License

private void displayAdvancedView() {

    if (this.getComponentCount() > 1) {
        this.removeComponent(this.getComponent(1));
    }/* ww w . j  a va 2  s .  c  o  m*/

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

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

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

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

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

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

    this.addComponent(bodyLayout);
}

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

License:Open Source License

private HorizontalLayout createHeaderRight() {
    final HorizontalLayout layout = new HorizontalLayout();

    this.createBtn = new Button(AppContext.getMessage(MilestoneI18nEnum.BUTTON_NEW_PHASE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override/* ww w.j  a  v  a 2s.  c o m*/
                public void buttonClick(final ClickEvent event) {
                    EventBusFactory.getInstance()
                            .post(new MilestoneEvent.GotoAdd(MilestoneListViewImpl.this, null));
                }
            });

    this.createBtn.setIcon(FontAwesome.PLUS);
    this.createBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    this.createBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES));
    layout.addComponent(this.createBtn);
    layout.setComponentAlignment(this.createBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

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

License:Open Source License

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

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

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

        @Override/*from  w w w .ja v a 2  s  .c  om*/
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new PageEvent.GotoList(PageListViewImpl.this, resource.getPath()));

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

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

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

        private static final long serialVersionUID = -5387015552598157076L;

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

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

                private static final long serialVersionUID = -5387015552598157076L;

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

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

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

    block.addComponent(controlBtns);

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

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

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

License:Open Source License

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

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

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

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

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

    block.addComponent(headerPanel);

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

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

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

        private static final long serialVersionUID = -5387015552598157076L;

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

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

                private static final long serialVersionUID = 2575434171770462361L;

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

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

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

    block.addComponent(controlBtns);

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

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

License:Open Source License

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

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

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

    notificationLabelWrapper.setStyleName("notification-label");

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

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

    bodyWrapper.addComponent(notificationLabelWrapper);

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

    final OptionGroup optionGroup = new OptionGroup(null);

    optionGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);

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

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

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

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

    optionGroup.setHeight("100%");

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

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

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

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

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

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

}

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  w  w w  .j  a v  a2 s.  co 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);
}