@Test public void testMakeMenuBar() { doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject(); doReturn(promises.resolve(true)).when(projectController).canUpdateProject(any()); loadContent(); verify(menuBuilderMock).addSave(any(MenuItem.class)); verify(menuBuilderMock).addCopy(any(Command.class)); verify(menuBuilderMock).addRename(any(Command.class)); verify(menuBuilderMock).addDelete(any(Command.class)); verify(menuBuilderMock).addNewTopLevelMenu(alertsButtonMenuItem); verify(menuBuilderMock).addNewTopLevelMenu(downloadMenuItem); presenter.getMenus(Assert::assertNotNull); verify(menuBuilderMock, atLeastOnce()).build(); }
@Override protected Promise<Void> makeMenuBar() { 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(this::safeCopy) .addRename(this::safeRename) .addDelete(this::safeDelete); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); }
FormEditorPresenter extends KieEditor<FormModelerContent> { @Override protected Promise<Void> makeMenuBar() { 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(this::safeCopy) .addRename(this::safeRename) .addDelete(this::safeDelete); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } }
FormEditorPresenter extends KieEditor<FormModelerContent> { @Override protected Promise<Void> makeMenuBar() { 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(this::safeCopy) .addRename(this::safeRename) .addDelete(this::safeDelete); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } @Inject  FormEditorPresenter(FormEditorView view,
                               ChangesNotificationDisplayer changesNotificationDisplayer,
                               FormDefinitionResourceType resourceType,
                               Caller<FormEditorService> editorService,
                               TranslationService translationService,
                               ManagedInstance<EditorFieldLayoutComponent> editorFieldLayoutComponents,
                               ShowAssetUsagesDisplayer showAssetUsagesDisplayer,
                               ErrorMessageDisplayer errorMessageDisplayer,
                               LayoutEditorPropertiesPresenter layoutEditorPropertiesPresenter); }
FormEditorPresenter extends KieEditor<FormModelerContent> { @Override protected Promise<Void> makeMenuBar() { 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(this::safeCopy) .addRename(this::safeRename) .addDelete(this::safeDelete); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } @Inject  FormEditorPresenter(FormEditorView view,
                               ChangesNotificationDisplayer changesNotificationDisplayer,
                               FormDefinitionResourceType resourceType,
                               Caller<FormEditorService> editorService,
                               TranslationService translationService,
                               ManagedInstance<EditorFieldLayoutComponent> editorFieldLayoutComponents,
                               ShowAssetUsagesDisplayer showAssetUsagesDisplayer,
                               ErrorMessageDisplayer errorMessageDisplayer,
                               LayoutEditorPropertiesPresenter layoutEditorPropertiesPresenter); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @OnFocus void onFocus(); @Override void hideDocks(); void doLoadContent(final FormModelerContent content); @Override @WorkbenchPartTitle String getTitleText(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @Override @WorkbenchPartView IsWidget getWidget(); void copy(boolean save); void rename(boolean save); LayoutTemplate getFormTemplate(); FormDefinition getFormDefinition(); void onRemoveComponent(@Observes ComponentRemovedEvent event); void onLayoutEditorElementSelectEvent(@Observes LayoutEditorElementSelectEvent event); void onSyncPalette(@Observes FormEditorSyncPaletteEvent event); void onSyncPalette(String formId); void safeDelete(); @OnMayClose Boolean onMayClose(); @PreDestroy void destroy(); void onLockStatusChange(@Observes UpdatedLockStatusEvent updatedLockStatusEvent); }
FormEditorPresenter extends KieEditor<FormModelerContent> { @Override protected Promise<Void> makeMenuBar() { 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(this::safeCopy) .addRename(this::safeRename) .addDelete(this::safeDelete); } addDownloadMenuItem(fileMenuBuilder); fileMenuBuilder .addNewTopLevelMenu(versionRecordManager.buildMenu()) .addNewTopLevelMenu(alertsButtonMenuItemBuilder.build()); return promises.resolve(); }); } return promises.resolve(); } @Inject  FormEditorPresenter(FormEditorView view,
                               ChangesNotificationDisplayer changesNotificationDisplayer,
                               FormDefinitionResourceType resourceType,
                               Caller<FormEditorService> editorService,
                               TranslationService translationService,
                               ManagedInstance<EditorFieldLayoutComponent> editorFieldLayoutComponents,
                               ShowAssetUsagesDisplayer showAssetUsagesDisplayer,
                               ErrorMessageDisplayer errorMessageDisplayer,
                               LayoutEditorPropertiesPresenter layoutEditorPropertiesPresenter); @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @OnFocus void onFocus(); @Override void hideDocks(); void doLoadContent(final FormModelerContent content); @Override @WorkbenchPartTitle String getTitleText(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @Override @WorkbenchPartView IsWidget getWidget(); void copy(boolean save); void rename(boolean save); LayoutTemplate getFormTemplate(); FormDefinition getFormDefinition(); void onRemoveComponent(@Observes ComponentRemovedEvent event); void onLayoutEditorElementSelectEvent(@Observes LayoutEditorElementSelectEvent event); void onSyncPalette(@Observes FormEditorSyncPaletteEvent event); void onSyncPalette(String formId); void safeDelete(); @OnMayClose Boolean onMayClose(); @PreDestroy void destroy(); void onLockStatusChange(@Observes UpdatedLockStatusEvent updatedLockStatusEvent); static final String ID; }