@Test public void testMakeMenuBarWithoutUpdateProjectPermission() { doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject(); doReturn(promises.resolve(false)).when(projectController).canUpdateProject(any()); presenter.makeMenuBar(); verify(fileMenuBuilder, never()).addSave(any(MenuItem.class)); verify(fileMenuBuilder, never()).addCopy(any(Path.class), any(AssetUpdateValidator.class)); verify(fileMenuBuilder, never()).addRename(any(Path.class), any(AssetUpdateValidator.class)); verify(fileMenuBuilder, never()).addDelete(any(Path.class), any(AssetUpdateValidator.class)); verify(fileMenuBuilder).addNewTopLevelMenu(alertsButtonMenuItem); }
@Override protected Promise<Void> makeMenuBar() { if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), assetUpdateValidator) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addValidate(getValidateCommand()) .addNewTopLevelMenu(getConvertMenu()) .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); }
DecisionTableXLSEditorPresenter extends KieEditor<DecisionTableXLSContent> implements DecisionTableXLSEditorView.Presenter { @Override protected Promise<Void> makeMenuBar() { if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), assetUpdateValidator) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addValidate(getValidateCommand()) .addNewTopLevelMenu(getConvertMenu()) .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } }
DecisionTableXLSEditorPresenter extends KieEditor<DecisionTableXLSContent> implements DecisionTableXLSEditorView.Presenter { @Override protected Promise<Void> makeMenuBar() { if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), assetUpdateValidator) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addValidate(getValidateCommand()) .addNewTopLevelMenu(getConvertMenu()) .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } @Inject  DecisionTableXLSEditorPresenter(final DecisionTableXLSEditorView baseView,
                                           final DecisionTableXLSResourceType decisionTableXLSResourceType,
                                           final DecisionTableXLSXResourceType decisionTableXLSXResourceType,
                                           final BusyIndicatorView busyIndicatorView,
                                           final ValidationPopup validationPopup,
                                           final Caller<DecisionTableXLSService> decisionTableXLSService,
                                           final Caller<MetadataService> metadataService); }
DecisionTableXLSEditorPresenter extends KieEditor<DecisionTableXLSContent> implements DecisionTableXLSEditorView.Presenter { @Override protected Promise<Void> makeMenuBar() { if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), assetUpdateValidator) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addValidate(getValidateCommand()) .addNewTopLevelMenu(getConvertMenu()) .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } @Inject  DecisionTableXLSEditorPresenter(final DecisionTableXLSEditorView baseView,
                                           final DecisionTableXLSResourceType decisionTableXLSResourceType,
                                           final DecisionTableXLSXResourceType decisionTableXLSXResourceType,
                                           final BusyIndicatorView busyIndicatorView,
                                           final ValidationPopup validationPopup,
                                           final Caller<DecisionTableXLSService> decisionTableXLSService,
                                           final Caller<MetadataService> metadataService); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @Override void onUpload(); @Override void onUploadSuccess(); @Override void onSourceTabSelected(); @OnClose @Override void onClose(); @WorkbenchPartTitleDecoration IsWidget getTitle(); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); }
DecisionTableXLSEditorPresenter extends KieEditor<DecisionTableXLSContent> implements DecisionTableXLSEditorView.Presenter { @Override protected Promise<Void> makeMenuBar() { if (workbenchContext.getActiveWorkspaceProject().isPresent()) { final WorkspaceProject activeProject = workbenchContext.getActiveWorkspaceProject().get(); return projectController.canUpdateProject(activeProject).then(canUpdateProject -> { if (canUpdateProject) { fileMenuBuilder .addSave(versionRecordManager.newSaveMenuItem(this::saveAction)) .addCopy(versionRecordManager.getCurrentPath(), assetUpdateValidator) .addRename(versionRecordManager.getPathToLatest(), assetUpdateValidator) .addDelete(versionRecordManager.getPathToLatest(), assetUpdateValidator); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addValidate(getValidateCommand()) .addNewTopLevelMenu(getConvertMenu()) .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } @Inject  DecisionTableXLSEditorPresenter(final DecisionTableXLSEditorView baseView,
                                           final DecisionTableXLSResourceType decisionTableXLSResourceType,
                                           final DecisionTableXLSXResourceType decisionTableXLSXResourceType,
                                           final BusyIndicatorView busyIndicatorView,
                                           final ValidationPopup validationPopup,
                                           final Caller<DecisionTableXLSService> decisionTableXLSService,
                                           final Caller<MetadataService> metadataService); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @Override void onUpload(); @Override void onUploadSuccess(); @Override void onSourceTabSelected(); @OnClose @Override void onClose(); @WorkbenchPartTitleDecoration IsWidget getTitle(); @WorkbenchPartTitle String getTitleText(); @WorkbenchPartView IsWidget getWidget(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); static final String EDITOR_ID; }