Example usage for com.vaadin.ui HorizontalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:com.esofthead.mycollab.module.crm.view.opportunity.OpportunityContactListComp.java

License:Open Source License

@Override
protected Component generateTopControls() {
    HorizontalLayout controlsBtnWrap = new HorizontalLayout();
    controlsBtnWrap.setWidth("100%");

    HorizontalLayout notesWrap = new HorizontalLayout();
    notesWrap.setWidth("100%");
    notesWrap.setSpacing(true);/* w  w  w  .  j a  v  a2 s  . c  o  m*/
    Label noteLbl = new Label("Note: ");
    noteLbl.setSizeUndefined();
    noteLbl.setStyleName("list-note-lbl");
    notesWrap.addComponent(noteLbl);

    CssLayout noteBlock = new CssLayout();
    noteBlock.setWidth("100%");
    noteBlock.setStyleName("list-note-block");
    for (int i = 0; i < CrmDataTypeFactory.getOpportunityContactRoleList().length; i++) {
        Label note = new Label(CrmDataTypeFactory.getOpportunityContactRoleList()[i]);
        note.setStyleName("note-label");
        note.addStyleName(colormap.get(CrmDataTypeFactory.getOpportunityContactRoleList()[i]));
        note.setSizeUndefined();

        noteBlock.addComponent(note);
    }
    notesWrap.addComponent(noteBlock);
    notesWrap.setExpandRatio(noteBlock, 1.0f);

    controlsBtnWrap.addComponent(notesWrap);

    final SplitButton controlsBtn = new SplitButton();
    controlsBtn.setSizeUndefined();
    controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT));
    controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK);
    controlsBtn.setCaption("Add/Edit Contacts' Role");
    controlsBtn.setIcon(FontAwesome.PLUS);
    controlsBtn.addClickListener(new SplitButton.SplitButtonClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void splitButtonClick(final SplitButton.SplitButtonClickEvent event) {
            EventBusFactory.getInstance().post(new OpportunityEvent.GotoContactRoleEdit(this, opportunity));
        }
    });
    final Button selectBtn = new Button("Select from existing contacts", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final ClickEvent event) {
            final OpportunityContactSelectionWindow contactsWindow = new OpportunityContactSelectionWindow(
                    OpportunityContactListComp.this);
            final ContactSearchCriteria criteria = new ContactSearchCriteria();
            criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId()));
            UI.getCurrent().addWindow(contactsWindow);
            contactsWindow.setSearchCriteria(criteria);
            controlsBtn.setPopupVisible(false);
        }
    });
    selectBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_select));
    selectBtn.setStyleName("link");
    VerticalLayout buttonControlLayout = new VerticalLayout();
    buttonControlLayout.addComponent(selectBtn);
    controlsBtn.setContent(buttonControlLayout);

    controlsBtnWrap.addComponent(controlsBtn);
    controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT);
    return controlsBtnWrap;
}

From source file:com.esofthead.mycollab.module.file.view.components.FileDashboardComponent.java

License:Open Source License

public HorizontalLayout constructHeader() {
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.setSpacing(true);/*  w w w. j ava 2s  .c  om*/
    layout.setMargin(true);

    final Image titleIcon = new Image(null, MyCollabResource.newResource("icons/24/project/file.png"));
    layout.addComponent(titleIcon);
    layout.setComponentAlignment(titleIcon, Alignment.MIDDLE_LEFT);

    final Label searchtitle = new Label("Files");
    searchtitle.setStyleName(Reindeer.LABEL_H2);
    layout.addComponent(searchtitle);
    layout.setComponentAlignment(searchtitle, Alignment.MIDDLE_LEFT);
    layout.setExpandRatio(searchtitle, 1.0f);
    return layout;
}

From source file:com.esofthead.mycollab.module.project.ui.components.GenericTaskTableDisplay.java

License:Open Source License

public GenericTaskTableDisplay(List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(ProjectGenericTaskService.class), ProjectGenericTask.class,
            displayColumns);//from   w w w  . j a va  2  s.  co  m

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

        @Override
        public com.vaadin.ui.Component generateCell(final Table source, final Object itemId,
                final Object columnId) {
            HorizontalLayout layout = new HorizontalLayout();

            final ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId);

            if (task.getType() != null) {
                FontIconLabel icon = new FontIconLabel(ProjectAssetsManager.getAsset(task.getType()));
                layout.addComponent(icon);
                layout.setComponentAlignment(icon, Alignment.MIDDLE_CENTER);
            }
            final ButtonLink b = new ButtonLink(task.getName(), new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    fireTableEvent(new TableClickEvent(GenericTaskTableDisplay.this, task, "name"));
                }
            });
            b.setWidth("100%");
            layout.addComponent(b);
            layout.setExpandRatio(b, 1.0f);
            layout.setWidth("100%");
            return layout;
        }
    });

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

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final ProjectGenericTask task = GenericTaskTableDisplay.this.getBeanByIndex(itemId);
            return new UserLink(task.getAssignUser(), task.getAssignUserAvatarId(),
                    task.getAssignUserFullName());
        }

    });

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

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

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

License:Open Source License

public BugTableDisplay(String viewId, TableViewField requiredColumn, List<TableViewField> displayColumns) {
    super(ApplicationContextUtil.getSpringBean(BugService.class), SimpleBug.class, viewId, requiredColumn,
            displayColumns);//w w  w .ja  v a 2 s .  com

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

        @Override
        public Object generateCell(final Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            final Button bugSettingBtn = new Button(null, FontAwesome.COG);
            bugSettingBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);

            final ContextMenu contextMenu = new ContextMenu();
            contextMenu.setAsContextMenuOf(bugSettingBtn);

            contextMenu.addItemClickListener(new ContextMenuItemClickListener() {

                @Override
                public void contextMenuItemClicked(ContextMenuItemClickEvent event) {
                    if (((ContextMenuItem) event.getSource()).getData() == null) {
                        return;
                    }

                    String category = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData())
                            .getAction();
                    String value = ((MenuItemData) ((ContextMenuItem) event.getSource()).getData()).getKey();
                    if ("status".equals(category)) {
                        if (AppContext.getMessage(BugStatus.Verified).equals(value)) {
                            UI.getCurrent().addWindow(new ApproveInputWindow(BugTableDisplay.this, bug));
                        } else if (AppContext.getMessage(BugStatus.InProgress).equals(value)) {
                            bug.setStatus(BugStatus.InProgress.name());
                            BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                            bugService.updateWithSession(bug, AppContext.getUsername());
                        } else if (AppContext.getMessage(BugStatus.Open).equals(value)) {
                            UI.getCurrent().addWindow(new ReOpenWindow(BugTableDisplay.this, bug));
                        } else if (AppContext.getMessage(BugStatus.Resolved).equals(value)) {
                            UI.getCurrent().addWindow(new ResolvedInputWindow(BugTableDisplay.this, bug));
                        }
                    } else if ("severity".equals(category)) {
                        bug.setSeverity(value);
                        BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateWithSession(bug, AppContext.getUsername());
                        refresh();
                    } else if ("priority".equals(category)) {
                        bug.setPriority(value);
                        BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class);
                        bugService.updateWithSession(bug, AppContext.getUsername());
                        refresh();
                    } else if ("action".equals(category)) {
                        if ("edit".equals(value)) {
                            EventBusFactory.getInstance()
                                    .post(new BugEvent.GotoEdit(BugTableDisplay.this, bug));
                        } else if ("delete".equals(value)) {
                            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()) {
                                                BugService bugService = ApplicationContextUtil
                                                        .getSpringBean(BugService.class);
                                                bugService.removeWithSession(bug.getId(),
                                                        AppContext.getUsername(), AppContext.getAccountId());
                                                refresh();
                                            }
                                        }
                                    });

                        }
                    }

                }
            });

            bugSettingBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));

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

                @Override
                public void buttonClick(ClickEvent event) {
                    displayContextMenuItem(contextMenu, bug, event.getClientX(), event.getClientY());
                }
            });
            return bugSettingBtn;
        }
    });

    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 SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(),
                    bug.getAssignuserFullName());
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new ProjectUserLink(bug.getLogby(), bug.getLoguserAvatarId(), bug.getLoguserFullName());
        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {

            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);

            String bugname = "[%s-%s] %s";
            bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(),
                    bug.getBugkey(), bug.getSummary());
            LabelLink b = new LabelLink(bugname,
                    ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName()));

            if (StringUtils.isNotBlank(bug.getPriority())) {
                b.setIconLink(ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority()));
            }

            b.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug,
                    AppContext.getSiteUrl(), AppContext.getTimezone()));

            if (bug.isCompleted()) {
                b.addStyleName(UIConstants.LINK_COMPLETED);
            } else if (bug.isOverdue()) {
                b.addStyleName(UIConstants.LINK_OVERDUE);
            }
            return b;

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);

            Resource iconPriority = new ExternalResource(
                    ProjectResources.getIconResourceLink12ByBugSeverity(bug.getPriority()));

            Embedded iconEmbedded = new Embedded(null, iconPriority);
            Label lbPriority = new Label(AppContext.getMessage(BugSeverity.class, bug.getSeverity()));
            HorizontalLayout containerField = new HorizontalLayout();
            containerField.setSpacing(true);
            containerField.addComponent(iconEmbedded);
            containerField.addComponent(lbPriority);
            containerField.setExpandRatio(lbPriority, 1.0f);
            return containerField;

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDate(bug.getDuedate()));

        }
    });

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

        @Override
        public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.formatDateTime(bug.getCreatedtime()));

        }
    });

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

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleBug bug = BugTableDisplay.this.getBeanByIndex(itemId);
            return new Label(AppContext.getMessage(BugResolution.class, bug.getResolution()));
        }
    });
    this.setWidth("100%");
}

From source file:com.esofthead.mycollab.module.project.view.bug.components.UnresolvedBugsByAssigneeWidget.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.getAssignedDefectsSummary(searchCriteria);
    if (!groupItems.isEmpty()) {
        for (final GroupItem item : groupItems) {
            final HorizontalLayout assigneeLayout = new HorizontalLayout();
            assigneeLayout.setSpacing(true);
            assigneeLayout.setWidth("100%");

            String assignUser = item.getGroupid();
            String assignUserFullName = item.getGroupid() == null
                    ? AppContext.getMessage(BugI18nEnum.OPT_UNDEFINED_USER)
                    : item.getGroupname();
            if (assignUserFullName == null || "".equals(assignUserFullName.trim())) {
                assignUserFullName = StringUtils.extractNameFromEmail(assignUser);
            }//from  ww w . ja v a  2  s .  c  om

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

            this.bodyContent.addComponent(assigneeLayout);
        }

    }
}

From source file:com.esofthead.mycollab.module.project.view.bug.components.UnresolvedBugsByAssigneeWidget2.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.getAssignedDefectsSummary(searchCriteria);
    if (!groupItems.isEmpty()) {
        for (final GroupItem item : groupItems) {
            final HorizontalLayout assigneeLayout = new HorizontalLayout();
            assigneeLayout.setSpacing(true);
            assigneeLayout.setWidth("100%");

            String assignUser = item.getGroupid();
            String assignUserFullName = item.getGroupid() == null
                    ? AppContext.getMessage(BugI18nEnum.OPT_UNDEFINED_USER)
                    : item.getGroupname();
            if (assignUserFullName == null || "".equals(assignUserFullName.trim())) {
                assignUserFullName = StringUtils.extractNameFromEmail(assignUser);
            }//from   w  w  w  .  j  a  va  2s  .  co m
            final BugAssigneeLink userLbl = new BugAssigneeLink(assignUser, item.getExtraValue(),
                    assignUserFullName);
            assigneeLayout.addComponent(userLbl);
            final ProgressBarIndicator indicator = new ProgressBarIndicator(totalCount,
                    totalCount - item.getValue(), false);
            indicator.setWidth("100%");
            assigneeLayout.addComponent(indicator);
            assigneeLayout.setExpandRatio(indicator, 1.0f);
            this.bodyContent.addComponent(assigneeLayout);
        }

    }
}

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;/*from ww  w .  j  a va  2s  . c om*/
                    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 ava  2  s.  c o  m*/
                    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.milestone.MilestoneBugListComp.java

License:Open Source License

private void constructHeader() {
    final HorizontalLayout header = new HorizontalLayout();
    header.setSpacing(true);//  www.  j  av  a  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));
    }//w  w  w  . j a  v  a  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);
}