@Override protected void onGo(final ComponentContainer container, final ScreenData<?> data) { if (CurrentProjectVariables.canRead(ProjectRolePermissionCollections.TASKS)) { InsideProjectNavigationMenu projectModuleMenu = (InsideProjectNavigationMenu) ((MobileNavigationManager) UI.getCurrent().getContent()).getNavigationMenu(); projectModuleMenu.selectButton(AppContext.getMessage(ProjectCommonI18nEnum.VIEW_TASK)); if (data.getParams() instanceof Integer) { ProjectTaskService taskService = ApplicationContextUtil.getSpringBean(ProjectTaskService.class); SimpleTask task = taskService.findById((Integer) data.getParams(), AppContext.getAccountId()); if (task != null) { this.view.previewItem(task); super.onGo(container, data); AppContext.addFragment( ProjectLinkGenerator.generateTaskPreviewLink( task.getTaskkey(), task.getProjectShortname()), task.getTaskname()); } else { NotificationUtil.showRecordNotExistNotification(); return; } } } else { NotificationUtil.showMessagePermissionAlert(); } }
@Override protected void onGo(ComponentContainer container, ScreenData<?> data) { if (CurrentProjectVariables.canRead(ProjectRolePermissionCollections.MILESTONES)) { super.onGo(container, data); view.displayStatus(OptionI18nEnum.MilestoneStatus.InProgress); AppContext.addFragment( "project/milestone/list/" + GenericLinkUtils.encodeParam(CurrentProjectVariables.getProjectId()), AppContext.getMessage(MilestoneI18nEnum.VIEW_LIST_TITLE)); } else { NotificationUtil.showMessagePermissionAlert(); } }
@Override protected void onGo(ComponentContainer container, ScreenData<?> data) { if (data instanceof ProjectScreenData.Edit) { // TODO: Handle edit project } else { if (CurrentProjectVariables.canRead(ProjectRolePermissionCollections.PROJECT)) { super.onGo(container, data); view.displayDashboard(); AppContext.addFragment( ProjectLinkGenerator.generateProjectLink(CurrentProjectVariables.getProject().getId()), AppContext.getMessage(ProjectCommonI18nEnum.VIEW_DASHBOARD)); } else { NotificationUtil.showMessagePermissionAlert(); } } }
public HorizontalLayout createButtonControls(int buttonEnableFlags, String permissionItem) { Button optionParentBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_OPTION), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { optionBtn.setPopupVisible(true); } }); optionBtn = new SplitButton(optionParentBtn); optionBtn.setWidthUndefined(); optionBtn.addStyleName(UIConstants.THEME_GRAY_LINK); if (permissionItem != null) { boolean canWrite = CurrentProjectVariables.canWrite(permissionItem); boolean canAccess = CurrentProjectVariables.canAccess(permissionItem); boolean canRead = CurrentProjectVariables.canRead(permissionItem); if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) { addBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_ADD), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireAddForm(item); } }); addBtn.setIcon(FontAwesome.PLUS); addBtn.setStyleName(UIConstants.THEME_GREEN_LINK); addBtn.setEnabled(canWrite); editButtons.addComponent(addBtn); } if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) { editBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireEditForm(item); } }); editBtn.setIcon(FontAwesome.EDIT); editBtn.setStyleName(UIConstants.THEME_GREEN_LINK); editBtn.setEnabled(canWrite); editButtons.addComponent(editBtn); } if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) { deleteBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireDeleteForm(item); } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.setStyleName(UIConstants.THEME_RED_LINK); deleteBtn.setEnabled(canAccess); editButtons.addComponent(deleteBtn); } if ((buttonEnableFlags & ASSIGN_BTN_PRESENTED) == ASSIGN_BTN_PRESENTED) { assignBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_ASSIGN), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireAssignForm(item); } }); assignBtn.setIcon(FontAwesome.SHARE); assignBtn.setStyleName(UIConstants.THEME_GREEN_LINK); editButtons.addComponent(assignBtn, 0); assignBtn.setEnabled(canWrite); } if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) { cloneBtn = new Button( AppContext.getMessage(GenericI18Enum.BUTTON_CLONE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireCloneForm(item); } }); cloneBtn.setIcon(FontAwesome.ROAD); cloneBtn.setStyleName("link"); cloneBtn.setEnabled(canWrite); popupButtonsControl.addOption(cloneBtn); } if (popupButtonsControl.getComponentCount() > 0) { optionBtn.setContent(popupButtonsControl); editButtons.addComponent(optionBtn); } layout.with(editButtons).withAlign(editButtons, Alignment.MIDDLE_RIGHT); if ((buttonEnableFlags & NAVIGATOR_BTN_PRESENTED) == NAVIGATOR_BTN_PRESENTED) { ButtonGroup navigationBtns = new ButtonGroup(); navigationBtns.setStyleName("navigation-btns"); Button previousItem = new Button( "<", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireGotoPrevious(item); } }); previousItem.setStyleName(UIConstants.THEME_GREEN_LINK); previousItem.setDescription( AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM)); previousItem.setEnabled(canRead); navigationBtns.addButton(previousItem); Button nextItemBtn = new Button( ">", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireGotoNextItem(item); } }); nextItemBtn.setStyleName(UIConstants.THEME_GREEN_LINK); nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM)); nextItemBtn.setEnabled(canRead); navigationBtns.addButton(nextItemBtn); layout.addComponent(navigationBtns); layout.setComponentAlignment(navigationBtns, Alignment.MIDDLE_RIGHT); } } return layout; }