List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
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);/*from ww w . j a v a 2 s . 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);// w w w . ja v a 2 s.c o 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.BugRelatedField.java
License:Open Source License
public void displayRelatedBugs(final SimpleBug bug) { this.bug = bug; VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setWidth("100%"); mainLayout.setMargin(true);/*from ww w. ja v a 2 s . co m*/ mainLayout.setSpacing(true); HorizontalLayout layoutAdd = new HorizontalLayout(); layoutAdd.setSpacing(true); Label lbBug = new Label("Bug:"); lbBug.setWidth("70px"); layoutAdd.addComponent(lbBug); layoutAdd.setComponentAlignment(lbBug, Alignment.MIDDLE_LEFT); itemField = new TextField(); itemField.setWidth("300px"); itemField.setNullRepresentation(""); itemField.setReadOnly(true); itemField.setEnabled(true); layoutAdd.addComponent(itemField); layoutAdd.setComponentAlignment(itemField, Alignment.MIDDLE_LEFT); browseBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { callItemSelectionWindow(); } }); browseBtn.setIcon(MyCollabResource.newResource(WebResourceIds._16_browseItem)); browseBtn.setStyleName("link"); layoutAdd.addComponent(browseBtn); layoutAdd.setComponentAlignment(browseBtn, Alignment.MIDDLE_LEFT); clearBtn = new Button("", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { setItemFieldValue(""); } }); clearBtn.setIcon(MyCollabResource.newResource("icons/16/clearItem.png")); clearBtn.setStyleName("link"); layoutAdd.addComponent(clearBtn); layoutAdd.setComponentAlignment(clearBtn, Alignment.MIDDLE_LEFT); Label lbIs = new Label("is"); layoutAdd.addComponent(lbIs); layoutAdd.setComponentAlignment(lbIs, Alignment.MIDDLE_LEFT); comboRelation = new BugRelationComboBox(); comboRelation.setWidth("200px"); layoutAdd.addComponent(comboRelation); layoutAdd.setComponentAlignment(comboRelation, Alignment.MIDDLE_LEFT); btnRelate = new Button("Relate"); btnRelate.setStyleName(UIConstants.THEME_GREEN_LINK); btnRelate.setIcon(MyCollabResource.newResource(WebResourceIds._16_addRecord)); ProjectMemberService memberService = ApplicationContextUtil.getSpringBean(ProjectMemberService.class); SimpleProjectMember member = memberService.findMemberByUsername(AppContext.getUsername(), CurrentProjectVariables.getProjectId(), AppContext.getAccountId()); if (member != null) { btnRelate.setEnabled((member.getIsadmin() || (AppContext.getUsername().equals(bug.getAssignuser())) || (AppContext.getUsername().equals(bug.getLogby()))) && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); } btnRelate.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { if (!itemField.getValue().toString().trim().equals("") && relatedBean != null && !relatedBean.getSummary().equals(bug.getSummary())) { SimpleRelatedBug relatedBug = new SimpleRelatedBug(); relatedBug.setBugid(bug.getId()); relatedBug.setRelatedid(relatedBean.getId()); relatedBug.setRelatetype((String) comboRelation.getValue()); relatedBug.setComment(txtComment.getValue().toString()); relatedBugService.saveWithSession(relatedBug, AppContext.getUsername()); SimpleRelatedBug oppositeRelation = new SimpleRelatedBug(); oppositeRelation.setBugid(relatedBean.getId()); oppositeRelation.setRelatedid(bug.getId()); oppositeRelation.setComment(txtComment.getValue().toString()); if (comboRelation.getValue().toString().equals(BugRelationConstants.PARENT)) { oppositeRelation.setRelatetype(BugRelationConstants.CHILD); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.CHILD)) { oppositeRelation.setRelatetype(BugRelationConstants.PARENT); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.RELATED)) { oppositeRelation.setRelatetype(BugRelationConstants.RELATED); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.BEFORE)) { oppositeRelation.setRelatetype(BugRelationConstants.AFTER); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.AFTER)) { oppositeRelation.setRelatetype(BugRelationConstants.BEFORE); } else if (comboRelation.getValue().toString().equals(BugRelationConstants.DUPLICATED)) { oppositeRelation.setRelatetype(BugRelationConstants.DUPLICATED); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); bug.setStatus(BugStatus.Resolved.name()); bug.setResolution(BugResolution.Duplicate.name()); bugService.updateWithSession(bug, AppContext.getUsername()); } relatedBugService.saveWithSession(oppositeRelation, AppContext.getUsername()); setCriteria(); setItemFieldValue(""); txtComment.setValue(""); relatedBean = null; } } }); layoutAdd.addComponent(btnRelate); layoutAdd.setComponentAlignment(btnRelate, Alignment.MIDDLE_LEFT); Label lbInstruction = new Label("<strong>Relate to an existing ticket</strong>", ContentMode.HTML); mainLayout.addComponent(lbInstruction); mainLayout.addComponent(layoutAdd); HorizontalLayout layoutComment = new HorizontalLayout(); layoutComment.setSpacing(true); Label lbComment = new Label("Comment:"); lbComment.setWidth("70px"); layoutComment.addComponent(lbComment); layoutComment.setComponentAlignment(lbComment, Alignment.TOP_LEFT); txtComment = new RichTextArea(); txtComment.setHeight("130px"); txtComment.setWidth("565px"); layoutComment.addComponent(txtComment); layoutComment.setComponentAlignment(txtComment, Alignment.MIDDLE_LEFT); mainLayout.addComponent(layoutComment); tableItem = new DefaultPagedBeanTable<RelatedBugService, BugRelatedSearchCriteria, SimpleRelatedBug>( ApplicationContextUtil.getSpringBean(RelatedBugService.class), SimpleRelatedBug.class, Arrays.asList( new TableViewField(BugI18nEnum.RELATED_BUG_NAME, "bugName", UIConstants.TABLE_EX_LABEL_WIDTH), new TableViewField(BugI18nEnum.RELATED_BUG_TYPE, "relatetype", UIConstants.TABLE_S_LABEL_WIDTH), new TableViewField(BugI18nEnum.RELATED_BUG_COMMENT, "comment", UIConstants.TABLE_EX_LABEL_WIDTH), new TableViewField(null, "id", UIConstants.TABLE_CONTROL_WIDTH))); tableItem.addGeneratedColumn("bugName", new Table.ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public com.vaadin.ui.Component generateCell(Table source, final Object itemId, Object columnId) { final SimpleRelatedBug relatedItem = tableItem.getBeanByIndex(itemId); String bugname = "[%s-%s] %s"; bugname = String.format(bugname, CurrentProjectVariables.getProject().getShortname(), relatedItem.getRelatedid(), relatedItem.getBugName()); BugService bugService = ApplicationContextUtil.getSpringBean(BugService.class); final SimpleBug bug = bugService.findById(relatedItem.getRelatedid(), AppContext.getAccountId()); LabelLink b = new LabelLink(bugname, ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); if (StringUtils.isNotBlank(bug.getPriority())) { String iconPriority = ProjectResources.getIconResourceLink12ByBugPriority(bug.getPriority()); b.setIconLink(iconPriority); } if (BugStatus.Verified.name().equals(bug.getStatus())) { b.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.getDuedate() != null && (bug.getDuedate().before(new GregorianCalendar().getTime()))) { b.addStyleName(UIConstants.LINK_OVERDUE); } b.setWidth("100%"); return b; } }); tableItem.addGeneratedColumn("id", new ColumnGenerator() { private static final long serialVersionUID = 1L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleRelatedBug relatedItem = tableItem.getBeanByIndex(itemId); Button deleteBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(com.vaadin.ui.Button.ClickEvent event) { BugRelatedSearchCriteria relateBugIdCriteria = new BugRelatedSearchCriteria(); relateBugIdCriteria.setBugId(new NumberSearchField(relatedItem.getBugid())); relateBugIdCriteria.setRelatedId(new NumberSearchField(relatedItem.getRelatedid())); relatedBugService.removeByCriteria(relateBugIdCriteria, AppContext.getAccountId()); BugRelatedSearchCriteria relateIdCriteria = new BugRelatedSearchCriteria(); relateIdCriteria.setBugId(new NumberSearchField(relatedItem.getRelatedid())); relateIdCriteria.setRelatedId(new NumberSearchField(relatedItem.getBugid())); relatedBugService.removeByCriteria(relateIdCriteria, AppContext.getAccountId()); BugRelatedField.this.setCriteria(); } }); deleteBtn.setStyleName("link"); deleteBtn.setIcon(MyCollabResource.newResource("icons/16/delete.png")); relatedItem.setExtraData(deleteBtn); ProjectMemberService memberService = ApplicationContextUtil .getSpringBean(ProjectMemberService.class); SimpleProjectMember member = memberService.findMemberByUsername(AppContext.getUsername(), CurrentProjectVariables.getProjectId(), AppContext.getAccountId()); if (member != null) { deleteBtn.setEnabled( member.getIsadmin() || (AppContext.getUsername().equals(bug.getAssignuser())) || (AppContext.getUsername().equals(bug.getLogby()))); } return deleteBtn; } }); mainLayout.addComponent(tableItem); setCriteria(); this.setCompositionRoot(mainLayout); }
From source file:com.esofthead.mycollab.module.project.view.bug.ComponentListViewImpl.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 w ww .jav a 2 s.c o m layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS); layoutWrapper.addComponent(layout); this.selectOptionButton = new SelectionOptionButton(this.tableItem); layout.addComponent(this.selectOptionButton); this.tableActionControls = new DefaultMassItemActionHandlersContainer(); if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.COMPONENTS)) { 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.bug.components.BugRowDisplayHandler.java
License:Open Source License
@Override public Component generateRow(SimpleBug bug, int rowIndex) { MVerticalLayout rowContent = new MVerticalLayout().withSpacing(false).withWidth("100%"); final LabelLink defectLink = new LabelLink( "[" + CurrentProjectVariables.getProject().getShortname() + "-" + bug.getBugkey() + "]: " + bug.getSummary(),/* www . ja v a 2 s . c o m*/ ProjectLinkBuilder.generateBugPreviewFullLink(bug.getBugkey(), bug.getProjectShortName())); defectLink.setWidth("100%"); defectLink.setIconLink(ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG)); defectLink.setDescription(ProjectTooltipGenerator.generateToolTipBug(AppContext.getUserLocale(), bug, AppContext.getSiteUrl(), AppContext.getTimezone())); if (bug.isCompleted()) { defectLink.addStyleName(UIConstants.LINK_COMPLETED); } else if (bug.isOverdue()) { defectLink.addStyleName(UIConstants.LINK_OVERDUE); } rowContent.addComponent(defectLink); final LabelHTMLDisplayWidget descInfo = new LabelHTMLDisplayWidget(bug.getDescription()); descInfo.setWidth("100%"); rowContent.addComponent(descInfo); final Label dateInfo = new Label(AppContext.getMessage(DayI18nEnum.LAST_UPDATED_ON, AppContext.formatPrettyTime(bug.getLastupdatedtime()))); dateInfo.setStyleName(UIConstants.WIDGET_ROW_METADATA); rowContent.addComponent(dateInfo); final HorizontalLayout hLayoutAssigneeInfo = new HorizontalLayout(); hLayoutAssigneeInfo.setSpacing(true); final Label assignee = new Label(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE) + ": "); assignee.setStyleName(UIConstants.WIDGET_ROW_METADATA); hLayoutAssigneeInfo.addComponent(assignee); hLayoutAssigneeInfo.setComponentAlignment(assignee, Alignment.MIDDLE_CENTER); final ProjectUserLink userLink = new ProjectUserLink(bug.getAssignuser(), bug.getAssignUserAvatarId(), bug.getAssignuserFullName(), false, true); hLayoutAssigneeInfo.addComponent(userLink); hLayoutAssigneeInfo.setComponentAlignment(userLink, Alignment.MIDDLE_CENTER); rowContent.addComponent(hLayoutAssigneeInfo); rowContent.setStyleName(UIConstants.WIDGET_ROW); if ((rowIndex + 1) % 2 != 0) { rowContent.addStyleName("odd"); } return rowContent; }
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 ww w. j a va2s.c o 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);// ww w. j ava2 s . 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.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/*from w ww. jav a 2 s .c om*/ 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.task.TaskGroupReorderViewImpl.java
License:Open Source License
private void constructHeader() { CssLayout headerWrapper = new CssLayout(); headerWrapper.setWidth("100%"); headerWrapper.addStyleName("taskgroup-header"); HorizontalLayout header = new HorizontalLayout(); header.setSpacing(true);/* w ww. j a v a2s. co m*/ header.setWidth("100%"); Label headerLbl = new Label("All Tasks"); headerLbl.setStyleName("h2"); header.addComponent(headerLbl); header.setComponentAlignment(headerLbl, Alignment.MIDDLE_LEFT); header.setExpandRatio(headerLbl, 1.0f); Button backToListBtn = new Button("Back to dashboard", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new TaskListEvent.GotoTaskListScreen(this, null)); } }); backToListBtn.setStyleName(UIConstants.THEME_GREEN_LINK); header.addComponent(backToListBtn); header.setComponentAlignment(backToListBtn, Alignment.MIDDLE_RIGHT); saveOrderBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance().post(new TaskListEvent.SaveReoderTaskList(event, changeSet)); } }); saveOrderBtn.setStyleName(UIConstants.THEME_GREEN_LINK); header.addComponent(saveOrderBtn); header.setComponentAlignment(saveOrderBtn, Alignment.MIDDLE_RIGHT); headerWrapper.addComponent(header); this.addComponent(headerWrapper); final DDVerticalLayout ddLayout = new DDVerticalLayout(); ddLayout.addStyleName("taskgroup-reorder"); ddLayout.setComponentVerticalDropRatio(0.3f); ddLayout.setDragMode(LayoutDragMode.CLONE); ddLayout.setDropHandler(new DropHandler() { private static final long serialVersionUID = 1L; @Override public AcceptCriterion getAcceptCriterion() { return new Not(VerticalLocationIs.MIDDLE); } @Override public void drop(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); DDVerticalLayout.VerticalLayoutTargetDetails details = (DDVerticalLayout.VerticalLayoutTargetDetails) event .getTargetDetails(); TaskListComponent comp = (TaskListComponent) transferable.getComponent(); int currentIndex = ddLayout.getComponentIndex(comp); int newIndex = details.getOverIndex(); ddLayout.removeComponent(comp); if (currentIndex > newIndex && details.getDropLocation() == VerticalDropLocation.BOTTOM) { newIndex++; } SimpleTaskList dropTaskList = comp.getTaskList(); dropTaskList.setGroupindex(newIndex); changeSet.add(dropTaskList); ddLayout.addComponent(comp, newIndex); // change affected task list items for (int i = 0; i < ddLayout.getComponentCount(); i++) { TaskListComponent affectedComp = (TaskListComponent) ddLayout.getComponent(i); SimpleTaskList affectedTaskList = affectedComp.getTaskList(); affectedTaskList.setGroupindex(i); changeSet.add(affectedTaskList); } } }); taskLists = new BeanList<ProjectTaskListService, TaskListSearchCriteria, SimpleTaskList>(null, ApplicationContextUtil.getSpringBean(ProjectTaskListService.class), TaskListRowDisplayHandler.class, ddLayout); this.addComponent(taskLists); }
From source file:com.esofthead.mycollab.module.project.view.TimeTrackingSummaryViewImpl.java
License:Open Source License
@Override public void display() { projects = ApplicationContextUtil.getSpringBean(ProjectService.class) .getProjectsUserInvolved(AppContext.getUsername(), AppContext.getAccountId()); if (CollectionUtils.isNotEmpty(projects)) { itemTimeLoggingService = ApplicationContextUtil.getSpringBean(ItemTimeLoggingService.class); final CssLayout headerWrapper = new CssLayout(); headerWrapper.setWidth("100%"); headerWrapper.setStyleName("projectfeed-hdr-wrapper"); HorizontalLayout loggingPanel = new HorizontalLayout(); HorizontalLayout controlBtns = new HorizontalLayout(); controlBtns.setMargin(new MarginInfo(true, false, true, false)); final Label layoutHeader = new Label( ProjectAssetsManager.getAsset(ProjectTypeConstants.TIME).getHtml() + " Time Tracking", ContentMode.HTML); layoutHeader.addStyleName("h2"); final MHorizontalLayout header = new MHorizontalLayout().withWidth("100%"); header.with(layoutHeader).withAlign(layoutHeader, Alignment.MIDDLE_LEFT).expand(layoutHeader); final CssLayout contentWrapper = new CssLayout(); contentWrapper.setWidth("100%"); contentWrapper.addStyleName(UIConstants.CONTENT_WRAPPER); headerWrapper.addComponent(header); this.addComponent(headerWrapper); contentWrapper.addComponent(controlBtns); MHorizontalLayout controlsPanel = new MHorizontalLayout().withWidth("100%"); contentWrapper.addComponent(controlsPanel); contentWrapper.addComponent(loggingPanel); this.addComponent(contentWrapper); final Button backBtn = new Button("Back to Workboard"); backBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w ww.j a va2 s .com*/ public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null)); } }); backBtn.addStyleName(UIConstants.THEME_GREEN_LINK); backBtn.setIcon(FontAwesome.ARROW_LEFT); controlBtns.addComponent(backBtn); VerticalLayout selectionLayoutWrapper = new VerticalLayout(); selectionLayoutWrapper.setWidth("100%"); selectionLayoutWrapper.addStyleName("time-tracking-summary-search-panel"); controlsPanel.addComponent(selectionLayoutWrapper); final GridLayout selectionLayout = new GridLayout(9, 2); selectionLayout.setSpacing(true); selectionLayout.setDefaultComponentAlignment(Alignment.TOP_RIGHT); selectionLayout.setMargin(true); selectionLayoutWrapper.addComponent(selectionLayout); Label fromLb = new Label("From:"); fromLb.setWidthUndefined(); selectionLayout.addComponent(fromLb, 0, 0); this.fromDateField = new PopupDateFieldExt(); this.fromDateField.setResolution(Resolution.DAY); this.fromDateField.setDateFormat(AppContext.getUserDateFormat()); this.fromDateField.setWidth("100px"); selectionLayout.addComponent(this.fromDateField, 1, 0); Label toLb = new Label("To:"); toLb.setWidthUndefined(); selectionLayout.addComponent(toLb, 2, 0); this.toDateField = new PopupDateFieldExt(); this.toDateField.setResolution(Resolution.DAY); this.toDateField.setDateFormat(AppContext.getUserDateFormat()); this.toDateField.setWidth("100px"); selectionLayout.addComponent(this.toDateField, 3, 0); Label groupLb = new Label("Group:"); groupLb.setWidthUndefined(); selectionLayout.addComponent(groupLb, 0, 1); this.groupField = new ValueComboBox(false, GROUPBY_PROJECT, GROUPBY_DATE, GROUPBY_USER); this.groupField.setWidth("100px"); selectionLayout.addComponent(this.groupField, 1, 1); Label sortLb = new Label("Sort:"); sortLb.setWidthUndefined(); selectionLayout.addComponent(sortLb, 2, 1); this.orderField = new ItemOrderComboBox(); this.orderField.setWidth("100px"); selectionLayout.addComponent(this.orderField, 3, 1); Label projectLb = new Label("Project:"); projectLb.setWidthUndefined(); selectionLayout.addComponent(projectLb, 4, 0); this.projectField = new UserInvolvedProjectsListSelect(); initListSelectStyle(this.projectField); selectionLayout.addComponent(this.projectField, 5, 0, 5, 1); Label userLb = new Label("User:"); userLb.setWidthUndefined(); selectionLayout.addComponent(userLb, 6, 0); this.userField = new UserInvolvedProjectsMemberListSelect(getProjectIds()); initListSelectStyle(this.userField); selectionLayout.addComponent(this.userField, 7, 0, 7, 1); final Button queryBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SUBMIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { fromDate = fromDateField.getValue(); toDate = toDateField.getValue(); searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate)); searchTimeReporting(); } }); queryBtn.setStyleName(UIConstants.THEME_GREEN_LINK); selectionLayout.addComponent(queryBtn, 8, 0); loggingPanel.setWidth("100%"); loggingPanel.setHeight("80px"); loggingPanel.setSpacing(true); totalHoursLoggingLabel = new Label("Total Hours Logging: 0 Hrs", ContentMode.HTML); totalHoursLoggingLabel.addStyleName(UIConstants.LAYOUT_LOG); totalHoursLoggingLabel.addStyleName(UIConstants.TEXT_LOG_DATE_FULL); loggingPanel.addComponent(totalHoursLoggingLabel); loggingPanel.setExpandRatio(totalHoursLoggingLabel, 1.0f); loggingPanel.setComponentAlignment(totalHoursLoggingLabel, Alignment.MIDDLE_LEFT); Button exportBtn = new Button("Export", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { exportButtonControl.setPopupVisible(true); } }); exportButtonControl = new SplitButton(exportBtn); exportButtonControl.setWidthUndefined(); exportButtonControl.addStyleName(UIConstants.THEME_GRAY_LINK); exportButtonControl.setIcon(FontAwesome.EXTERNAL_LINK); VerticalLayout popupButtonsControl = new VerticalLayout(); exportButtonControl.setContent(popupButtonsControl); Button exportPdfBtn = new Button("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("Excel"); FileDownloader excelDownloader = new FileDownloader(constructStreamResource(ReportExportType.EXCEL)); excelDownloader.extend(exportExcelBtn); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); exportExcelBtn.setStyleName("link"); popupButtonsControl.addComponent(exportExcelBtn); controlBtns.addComponent(exportButtonControl); controlBtns.setComponentAlignment(exportButtonControl, Alignment.TOP_RIGHT); controlBtns.setComponentAlignment(backBtn, Alignment.TOP_LEFT); controlBtns.setSizeFull(); this.timeTrackingWrapper = new VerticalLayout(); this.timeTrackingWrapper.setWidth("100%"); contentWrapper.addComponent(this.timeTrackingWrapper); Calendar date = new GregorianCalendar(); date.set(Calendar.DAY_OF_MONTH, 1); fromDate = date.getTime(); date.add(Calendar.DAY_OF_MONTH, date.getActualMaximum(Calendar.DAY_OF_MONTH)); toDate = date.getTime(); fromDateField.setValue(fromDate); toDateField.setValue(toDate); searchCriteria = new ItemTimeLoggingSearchCriteria(); searchCriteria.setRangeDate(new RangeDateSearchField(fromDate, toDate)); } else { final Button backBtn = new Button("Back to Workboard"); backBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(TimeTrackingSummaryViewImpl.this, null)); } }); backBtn.addStyleName(UIConstants.THEME_GREEN_LINK); backBtn.setIcon(FontAwesome.ARROW_LEFT); VerticalLayout contentWrapper = new VerticalLayout(); contentWrapper.setSpacing(true); Label infoLbl = new Label("You are not involved in any project yet to track time working"); infoLbl.setWidthUndefined(); contentWrapper.setMargin(true); contentWrapper.addComponent(infoLbl); contentWrapper.setComponentAlignment(infoLbl, Alignment.MIDDLE_CENTER); contentWrapper.addComponent(backBtn); contentWrapper.setComponentAlignment(backBtn, Alignment.MIDDLE_CENTER); this.addComponent(contentWrapper); this.setComponentAlignment(contentWrapper, Alignment.MIDDLE_CENTER); } }