@Test public void testMakeMenuBar() { final Command saveAndRenameCommand = mock(Command.class); doNothing().when(presenter).addDownloadMenuItem(any()); doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject(); when(projectController.canUpdateProject(any())).thenReturn(promises.resolve(true)); doReturn(saveAndRenameCommand).when(presenter).getSaveAndRename(); presenter.makeMenuBar(); verify(getMenuSessionItems()).populateMenu(eq(fileMenuBuilder)); verify(fileMenuBuilder).addSave(any(MenuItem.class)); verify(fileMenuBuilder).addCopy(any(Path.class), any(AssetUpdateValidator.class)); verify(fileMenuBuilder).addRename(saveAndRenameCommand); verify(fileMenuBuilder).addDelete(any(Path.class), any(AssetUpdateValidator.class)); verify(presenter).addDownloadMenuItem(fileMenuBuilder); }
@Override protected Promise<Void> makeMenuBar() { if (!menuBarInitialzed) { menuSessionItems.populateMenu(fileMenuBuilder); makeAdditionalStunnerMenus(fileMenuBuilder); if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { final ParameterizedCommand<Boolean> onSave = withComments -> { saveWithComments = withComments; saveAction(); }; fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(onSave)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); menuBarInitialzed = true; return promises.resolve(); }); } } return promises.resolve(); }
AbstractProjectDiagramEditor extends KieEditor<ProjectDiagramResource> implements DiagramEditorCore<ProjectMetadata, ProjectDiagram> { @Override protected Promise<Void> makeMenuBar() { if (!menuBarInitialzed) { menuSessionItems.populateMenu(fileMenuBuilder); makeAdditionalStunnerMenus(fileMenuBuilder); if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { final ParameterizedCommand<Boolean> onSave = withComments -> { saveWithComments = withComments; saveAction(); }; fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(onSave)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); menuBarInitialzed = true; return promises.resolve(); }); } } return promises.resolve(); } }
AbstractProjectDiagramEditor extends KieEditor<ProjectDiagramResource> implements DiagramEditorCore<ProjectMetadata, ProjectDiagram> { @Override protected Promise<Void> makeMenuBar() { if (!menuBarInitialzed) { menuSessionItems.populateMenu(fileMenuBuilder); makeAdditionalStunnerMenus(fileMenuBuilder); if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { final ParameterizedCommand<Boolean> onSave = withComments -> { saveWithComments = withComments; saveAction(); }; fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(onSave)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); menuBarInitialzed = true; return promises.resolve(); }); } } return promises.resolve(); } AbstractProjectDiagramEditor(final AbstractProjectDiagramEditor.View view,
                                        final TextEditorView xmlEditorView,
                                        final ManagedInstance<SessionEditorPresenter<EditorSession>> editorSessionPresenterInstances,
                                        final ManagedInstance<SessionViewerPresenter<ViewerSession>> viewerSessionPresenterInstances,
                                        final Event<OnDiagramFocusEvent> onDiagramFocusEvent,
                                        final Event<OnDiagramLoseFocusEvent> onDiagramLostFocusEvent,
                                        final Event<NotificationEvent> notificationEvent,
                                        final ErrorPopupPresenter errorPopupPresenter,
                                        final DiagramClientErrorHandler diagramClientErrorHandler,
                                        final DocumentationView documentationView,
                                        final R resourceType,
                                        final AbstractDiagramEditorMenuSessionItems<?> menuSessionItems,
                                        final ProjectMessagesListener projectMessagesListener,
                                        final ClientTranslationService translationService,
                                        final ClientProjectDiagramService projectDiagramServices,
                                        final Caller<ProjectDiagramResourceService> projectDiagramResourceServiceCaller); }
AbstractProjectDiagramEditor extends KieEditor<ProjectDiagramResource> implements DiagramEditorCore<ProjectMetadata, ProjectDiagram> { @Override protected Promise<Void> makeMenuBar() { if (!menuBarInitialzed) { menuSessionItems.populateMenu(fileMenuBuilder); makeAdditionalStunnerMenus(fileMenuBuilder); if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { final ParameterizedCommand<Boolean> onSave = withComments -> { saveWithComments = withComments; saveAction(); }; fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(onSave)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); menuBarInitialzed = true; return promises.resolve(); }); } } return promises.resolve(); } AbstractProjectDiagramEditor(final AbstractProjectDiagramEditor.View view,
                                        final TextEditorView xmlEditorView,
                                        final ManagedInstance<SessionEditorPresenter<EditorSession>> editorSessionPresenterInstances,
                                        final ManagedInstance<SessionViewerPresenter<ViewerSession>> viewerSessionPresenterInstances,
                                        final Event<OnDiagramFocusEvent> onDiagramFocusEvent,
                                        final Event<OnDiagramLoseFocusEvent> onDiagramLostFocusEvent,
                                        final Event<NotificationEvent> notificationEvent,
                                        final ErrorPopupPresenter errorPopupPresenter,
                                        final DiagramClientErrorHandler diagramClientErrorHandler,
                                        final DocumentationView documentationView,
                                        final R resourceType,
                                        final AbstractDiagramEditorMenuSessionItems<?> menuSessionItems,
                                        final ProjectMessagesListener projectMessagesListener,
                                        final ClientTranslationService translationService,
                                        final ClientProjectDiagramService projectDiagramServices,
                                        final Caller<ProjectDiagramResourceService> projectDiagramResourceServiceCaller); @PostConstruct @SuppressWarnings("unchecked") void init(); @Override RemoteCallback<Path> getSaveSuccessCallback(final int newHash); @Override void hideDocks(); @Override void showDocks(); @Override //Override visibility from KieEditor to allow inner class ProjectDiagramEditorCore access abstract String getEditorIdentifier(); @Override String getTitleText(); @Override void open(final ProjectDiagram diagram,
                     final Viewer.Callback callback); @Override Annotation[] getDockQualifiers(); @Override void initialiseKieEditorForSession(final ProjectDiagram diagram); @SuppressWarnings("unchecked") void addDocumentationPage(final ProjectDiagram diagram); @Override SessionEditorPresenter<EditorSession> newSessionEditorPresenter(); @Override SessionViewerPresenter<ViewerSession> newSessionViewerPresenter(); @Override int getCurrentDiagramHash(); @Override CanvasHandler getCanvasHandler(); @Override void onSaveError(final ClientRuntimeError error); @Override SessionPresenter<? extends ClientSession, ?, Diagram> getSessionPresenter(); @Override void doFocus(); @Override void doLostFocus(); AbstractDiagramEditorMenuSessionItems getMenuSessionItems(); }
AbstractProjectDiagramEditor extends KieEditor<ProjectDiagramResource> implements DiagramEditorCore<ProjectMetadata, ProjectDiagram> { @Override protected Promise<Void> makeMenuBar() { if (!menuBarInitialzed) { menuSessionItems.populateMenu(fileMenuBuilder); makeAdditionalStunnerMenus(fileMenuBuilder); if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { final ParameterizedCommand<Boolean> onSave = withComments -> { saveWithComments = withComments; saveAction(); }; fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(onSave)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(getSaveAndRename()) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); menuBarInitialzed = true; return promises.resolve(); }); } } return promises.resolve(); } AbstractProjectDiagramEditor(final AbstractProjectDiagramEditor.View view,
                                        final TextEditorView xmlEditorView,
                                        final ManagedInstance<SessionEditorPresenter<EditorSession>> editorSessionPresenterInstances,
                                        final ManagedInstance<SessionViewerPresenter<ViewerSession>> viewerSessionPresenterInstances,
                                        final Event<OnDiagramFocusEvent> onDiagramFocusEvent,
                                        final Event<OnDiagramLoseFocusEvent> onDiagramLostFocusEvent,
                                        final Event<NotificationEvent> notificationEvent,
                                        final ErrorPopupPresenter errorPopupPresenter,
                                        final DiagramClientErrorHandler diagramClientErrorHandler,
                                        final DocumentationView documentationView,
                                        final R resourceType,
                                        final AbstractDiagramEditorMenuSessionItems<?> menuSessionItems,
                                        final ProjectMessagesListener projectMessagesListener,
                                        final ClientTranslationService translationService,
                                        final ClientProjectDiagramService projectDiagramServices,
                                        final Caller<ProjectDiagramResourceService> projectDiagramResourceServiceCaller); @PostConstruct @SuppressWarnings("unchecked") void init(); @Override RemoteCallback<Path> getSaveSuccessCallback(final int newHash); @Override void hideDocks(); @Override void showDocks(); @Override //Override visibility from KieEditor to allow inner class ProjectDiagramEditorCore access abstract String getEditorIdentifier(); @Override String getTitleText(); @Override void open(final ProjectDiagram diagram,
                     final Viewer.Callback callback); @Override Annotation[] getDockQualifiers(); @Override void initialiseKieEditorForSession(final ProjectDiagram diagram); @SuppressWarnings("unchecked") void addDocumentationPage(final ProjectDiagram diagram); @Override SessionEditorPresenter<EditorSession> newSessionEditorPresenter(); @Override SessionViewerPresenter<ViewerSession> newSessionViewerPresenter(); @Override int getCurrentDiagramHash(); @Override CanvasHandler getCanvasHandler(); @Override void onSaveError(final ClientRuntimeError error); @Override SessionPresenter<? extends ClientSession, ?, Diagram> getSessionPresenter(); @Override void doFocus(); @Override void doLostFocus(); AbstractDiagramEditorMenuSessionItems getMenuSessionItems();  }