@Override protected Component generateTopControls() { VerticalLayout controlsBtnWrap = new VerticalLayout(); controlsBtnWrap.setWidth("100%"); final SplitButton controlsBtn = new SplitButton(); controlsBtn.addStyleName(UIConstants.THEME_GREEN_LINK); controlsBtn.setCaption(AppContext.getMessage(OpportunityI18nEnum.BUTTON_NEW_OPPORTUNITY)); controlsBtn.setIcon(FontAwesome.PLUS); controlsBtn.addClickListener( new SplitButton.SplitButtonClickListener() { private static final long serialVersionUID = 1L; @Override public void splitButtonClick(SplitButton.SplitButtonClickEvent event) { fireNewRelatedItem(""); } }); controlsBtn.setSizeUndefined(); Button selectBtn = new Button( "Select from existing opportunities", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(Button.ClickEvent event) { ContactOpportunitySelectionWindow opportunitiesWindow = new ContactOpportunitySelectionWindow(ContactOpportunityListComp.this); OpportunitySearchCriteria criteria = new OpportunitySearchCriteria(); criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId())); UI.getCurrent().addWindow(opportunitiesWindow); opportunitiesWindow.setSearchCriteria(criteria); controlsBtn.setPopupVisible(false); } }); selectBtn.setIcon(CrmAssetsManager.getAsset(CrmTypeConstants.OPPORTUNITY)); OptionPopupContent buttonControlsLayout = new OptionPopupContent(); buttonControlsLayout.addOption(selectBtn); controlsBtn.setContent(buttonControlsLayout); controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_OPPORTUNITY)); controlsBtnWrap.addComponent(controlsBtn); controlsBtnWrap.setComponentAlignment(controlsBtn, Alignment.MIDDLE_RIGHT); return controlsBtnWrap; }
@SuppressWarnings("serial") private void initUI() { final SplitButton controlsBtn = new SplitButton(); controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT)); controlsBtn.addStyleName(UIConstants.THEME_BLUE_LINK); controlsBtn.setCaption("New Contact"); controlsBtn.setIcon(MyCollabResource.newResource("icons/16/addRecord.png")); controlsBtn.addClickListener( new SplitButton.SplitButtonClickListener() { @Override public void splitButtonClick(SplitButton.SplitButtonClickEvent event) { fireNewRelatedItem(""); } }); Button selectBtn = new Button( "Select from existing contacts", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { CaseContactSelectionWindow contactsWindow = new CaseContactSelectionWindow(CaseContactListComp.this); ContactSearchCriteria criteria = new ContactSearchCriteria(); criteria.setSaccountid(new NumberSearchField(AppContext.getAccountId())); UI.getCurrent().addWindow(contactsWindow); contactsWindow.setSearchCriteria(criteria); controlsBtn.setPopupVisible(false); } }); selectBtn.setIcon(MyCollabResource.newResource("icons/16/select.png")); selectBtn.setStyleName("link"); VerticalLayout buttonControlsLayout = new VerticalLayout(); buttonControlsLayout.addComponent(selectBtn); controlsBtn.setContent(buttonControlsLayout); controlsBtn.setEnabled(AppContext.canWrite(RolePermissionCollections.CRM_CONTACT)); this.addComponent(controlsBtn); tableItem = new ContactTableDisplay( Arrays.asList( ContactTableFieldDef.name, ContactTableFieldDef.email, ContactTableFieldDef.phoneOffice, ContactTableFieldDef.account, ContactTableFieldDef.action)); tableItem.addTableListener( new ApplicationEventListener<TableClickEvent>() { @Override public Class<? extends ApplicationEvent> getEventType() { return TableClickEvent.class; } @Override public void handle(TableClickEvent event) { SimpleContact contact = (SimpleContact) event.getData(); if ("contactName".equals(event.getFieldName())) { EventBus.getInstance() .fireEvent(new ContactEvent.GotoRead(CaseContactListComp.this, contact.getId())); } } }); tableItem.addGeneratedColumn( "id", new Table.ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { final SimpleContact contact = (SimpleContact) tableItem.getBeanByIndex(itemId); HorizontalLayout controlLayout = new HorizontalLayout(); Button editBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EventBus.getInstance() .fireEvent( new ContactEvent.GotoEdit(CaseContactListComp.this, contact)); } }); editBtn.setStyleName("link"); editBtn.setIcon(MyCollabResource.newResource("icons/16/edit.png")); controlLayout.addComponent(editBtn); Button deleteBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { ConfirmDialogExt.show( UI.getCurrent(), LocalizationHelper.getMessage( GenericI18Enum.DELETE_DIALOG_TITLE, SiteConfiguration.getSiteName()), LocalizationHelper.getMessage( CrmCommonI18nEnum.DIALOG_DELETE_RELATIONSHIP_TITLE), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_YES_LABEL), LocalizationHelper.getMessage(GenericI18Enum.BUTTON_NO_LABEL), new ConfirmDialog.Listener() { private static final long serialVersionUID = 1L; @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { ContactService contactService = ApplicationContextUtil.getSpringBean(ContactService.class); ContactCase associateContact = new ContactCase(); associateContact.setCaseid(cases.getId()); associateContact.setContactid(contact.getId()); contactService.removeContactCaseRelationship( associateContact, AppContext.getAccountId()); CaseContactListComp.this.refresh(); } } }); } }); deleteBtn.setStyleName("link"); deleteBtn.setIcon(MyCollabResource.newResource("icons/16/delete.png")); controlLayout.addComponent(deleteBtn); return controlLayout; } }); this.addComponent(tableItem); }
public TaskDashboardViewImpl() { this.withMargin(new MarginInfo(false, true, true, true)); taskSearchPanel = new TaskSearchPanel(); MHorizontalLayout groupWrapLayout = new MHorizontalLayout(); groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); groupWrapLayout.addComponent(new Label("Filter:")); final TaskSavedFilterComboBox savedFilterComboBox = new TaskSavedFilterComboBox(); savedFilterComboBox.addQuerySelectListener( new SavedFilterComboBox.QuerySelectListener() { @Override public void querySelect(SavedFilterComboBox.QuerySelectEvent querySelectEvent) { List<SearchFieldInfo> fieldInfos = querySelectEvent.getSearchFieldInfos(); TaskSearchCriteria criteria = SearchFieldInfo.buildSearchCriteria(TaskSearchCriteria.class, fieldInfos); criteria.setProjectid(new NumberSearchField(CurrentProjectVariables.getProjectId())); EventBusFactory.getInstance() .post(new TaskEvent.SearchRequest(TaskDashboardViewImpl.this, criteria)); } }); groupWrapLayout.addComponent(savedFilterComboBox); groupWrapLayout.addComponent(new Label("Sort:")); final ComboBox sortCombo = new ValueComboBox(false, DESCENDING, ASCENDING); sortCombo.setWidth("100px"); sortCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String sortValue = (String) sortCombo.getValue(); if (ASCENDING.equals(sortValue)) { sortDirection = SearchCriteria.ASC; } else { sortDirection = SearchCriteria.DESC; } queryAndDisplayTasks(); } }); sortDirection = SearchCriteria.DESC; groupWrapLayout.addComponent(sortCombo); groupWrapLayout.addComponent(new Label("Group by:")); final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, PLAIN_LIST); groupCombo.setWidth("100px"); groupCombo.addValueChangeListener( new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { groupByState = (String) groupCombo.getValue(); queryAndDisplayTasks(); } }); groupByState = GROUP_DUE_DATE; groupWrapLayout.addComponent(groupCombo); taskSearchPanel.addHeaderRight(groupWrapLayout); Button exportBtn = new Button("Export"); final SplitButton exportSplitBtn = new SplitButton(exportBtn); exportBtn.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { exportSplitBtn.setPopupVisible(true); } }); exportSplitBtn.addStyleName(UIConstants.THEME_GREEN_LINK); OptionPopupContent popupButtonsControl = new OptionPopupContent(); Button exportPdfBtn = new Button("PDF"); exportPdfBtn.setIcon(FontAwesome.FILE_PDF_O); FileDownloader pdfFileDownloder = new FileDownloader(buildStreamSource(ReportExportType.PDF)); pdfFileDownloder.extend(exportPdfBtn); popupButtonsControl.addOption(exportPdfBtn); Button exportExcelBtn = new Button("Excel"); exportExcelBtn.setIcon(FontAwesome.FILE_EXCEL_O); FileDownloader excelFileDownloader = new FileDownloader(buildStreamSource(ReportExportType.EXCEL)); excelFileDownloader.extend(exportExcelBtn); popupButtonsControl.addOption(exportExcelBtn); exportSplitBtn.setContent(popupButtonsControl); groupWrapLayout.with(exportSplitBtn); Button newTaskBtn = new Button( AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASK), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { SimpleTask newTask = new SimpleTask(); newTask.setProjectid(CurrentProjectVariables.getProjectId()); UI.getCurrent().addWindow(new TaskAddWindow(newTask)); } }); newTaskBtn.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)); newTaskBtn.setIcon(FontAwesome.PLUS); newTaskBtn.setDescription(AppContext.getMessage(TaskI18nEnum.BUTTON_NEW_TASKGROUP)); newTaskBtn.setStyleName(UIConstants.THEME_GREEN_LINK); groupWrapLayout.addComponent(newTaskBtn); Button advanceDisplayBtn = new Button(); advanceDisplayBtn.setWidth("50px"); advanceDisplayBtn.setIcon(FontAwesome.SITEMAP); advanceDisplayBtn.setDescription( AppContext.getMessage(TaskGroupI18nEnum.ADVANCED_VIEW_TOOLTIP)); Button calendarBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new TaskEvent.GotoCalendarView(TaskDashboardViewImpl.this)); } }); calendarBtn.setWidth("50px"); calendarBtn.setDescription("Calendar View"); calendarBtn.setIcon(FontAwesome.CALENDAR); Button chartDisplayBtn = new Button( null, new Button.ClickListener() { private static final long serialVersionUID = -5707546605789537298L; @Override public void buttonClick(ClickEvent event) { displayGanttChartView(); } }); chartDisplayBtn.setWidth("50px"); chartDisplayBtn.setDescription("Display Gantt chart"); chartDisplayBtn.setIcon(FontAwesome.BAR_CHART_O); Button kanbanBtn = new Button( null, new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { displayKanbanView(); } }); kanbanBtn.setWidth("50px"); kanbanBtn.setDescription("Kanban View"); kanbanBtn.setIcon(FontAwesome.TH); ToggleButtonGroup viewButtons = new ToggleButtonGroup(); viewButtons.addButton(advanceDisplayBtn); viewButtons.addButton(calendarBtn); viewButtons.addButton(kanbanBtn); viewButtons.addButton(chartDisplayBtn); viewButtons.setDefaultButton(advanceDisplayBtn); groupWrapLayout.addComponent(viewButtons); mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth(); wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false)); rightColumn = new MVerticalLayout() .withWidth("350px") .withMargin(new MarginInfo(true, false, false, false)); mainLayout.with(wrapBody, rightColumn).expand(wrapBody); }