From 8846d4c119f7a9d7f6c755a29dcdf959d14da01e Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Mon, 24 Apr 2017 10:29:53 +0200
Subject: [PATCH] ref #6566 Add generic "open part" handler to model fragment
---
.../fragment.e4xmi | 4 +
.../taxeditor/workbench/AppModelId.java | 74 +++++++++++++++++++
.../taxeditor/workbench/OpenPartHandler.java | 30 ++++++++
3 files changed, 108 insertions(+)
create mode 100644 eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/AppModelId.java
create mode 100644 eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/OpenPartHandler.java
diff --git a/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi b/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
index 4202bb2be..2d207ed6a 100644
--- a/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
+++ b/eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
@@ -101,6 +101,9 @@
+
+
+
@@ -110,5 +113,6 @@
+
diff --git a/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/AppModelId.java b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/AppModelId.java
new file mode 100644
index 000000000..7edd35894
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/AppModelId.java
@@ -0,0 +1,74 @@
+package eu.etaxonomy.taxeditor.workbench;
+
+public class AppModelId {
+ public static final String COMMANDPARAMETER_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_COMMANDPARAMETER_PARTNAME = "eu.etaxonomy.taxeditor.workbench.commandparameter.partName";
+ public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_COMMAND_OPENPART = "eu.etaxonomy.taxeditor.command.openPart";
+ public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_INSTALL = "eu.etaxonomy.taxeditor.install";
+ public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_UPDATE = "eu.etaxonomy.taxeditor.update";
+ public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_DATABASEREPAIRFUNCTIONALITY = "eu.etaxonomy.taxeditor.workbench.DatabaseRepairFunctionality";
+ public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_DATABASESETTINGS = "eu.etaxonomy.taxeditor.workbench.DatabaseSettings";
+ public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_HELP_ABOUTPLATFORM = "eu.etaxonomy.taxeditor.workbench.help.aboutPlatform";
+ public static final String COMMAND_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_HELP_PARSER = "eu.etaxonomy.taxeditor.workbench.help.parser";
+ public static final String COMMAND_ORG_ECLIPSE_UI_EDIT_COPY = "org.eclipse.ui.edit.copy";
+ public static final String COMMAND_ORG_ECLIPSE_UI_EDIT_CUT = "org.eclipse.ui.edit.cut";
+ public static final String COMMAND_ORG_ECLIPSE_UI_EDIT_DELETE = "org.eclipse.ui.edit.delete";
+ public static final String COMMAND_ORG_ECLIPSE_UI_EDIT_PASTE = "org.eclipse.ui.edit.paste";
+ public static final String COMMAND_ORG_ECLIPSE_UI_EDIT_REDO = "org.eclipse.ui.edit.redo";
+ public static final String COMMAND_ORG_ECLIPSE_UI_EDIT_UNDO = "org.eclipse.ui.edit.undo";
+ public static final String COMMAND_ORG_ECLIPSE_UI_FILE_CLOSE = "org.eclipse.ui.file.close";
+ public static final String COMMAND_ORG_ECLIPSE_UI_FILE_CLOSEALL = "org.eclipse.ui.file.closeAll";
+ public static final String COMMAND_ORG_ECLIPSE_UI_FILE_EXIT = "org.eclipse.ui.file.exit";
+ public static final String COMMAND_ORG_ECLIPSE_UI_FILE_EXPORT = "org.eclipse.ui.file.export";
+ public static final String COMMAND_ORG_ECLIPSE_UI_FILE_IMPORT = "org.eclipse.ui.file.import";
+ public static final String COMMAND_ORG_ECLIPSE_UI_FILE_SAVE = "org.eclipse.ui.file.save";
+ public static final String COMMAND_ORG_ECLIPSE_UI_FILE_SAVEALL = "org.eclipse.ui.file.saveAll";
+ public static final String COMMAND_ORG_ECLIPSE_UI_HELP_ABOUTACTION = "org.eclipse.ui.help.aboutAction";
+ public static final String COMMAND_ORG_ECLIPSE_UI_HELP_DYNAMICHELP = "org.eclipse.ui.help.dynamicHelp";
+ public static final String COMMAND_ORG_ECLIPSE_UI_HELP_HELPCONTENTS = "org.eclipse.ui.help.helpContents";
+ public static final String COMMAND_ORG_ECLIPSE_UI_HELP_HELPSEARCH = "org.eclipse.ui.help.helpSearch";
+ public static final String COMMAND_ORG_ECLIPSE_UI_NEWWIZARD = "org.eclipse.ui.newWizard";
+ public static final String COMMAND_ORG_ECLIPSE_UI_WINDOW_PREFERENCES = "org.eclipse.ui.window.preferences";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_APPLICATION_HANDLEDMENUITEM_CLOSE = "eu.etaxonomy.taxeditor.application.handledmenuitem.close";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_APPLICATION_HANDLEDMENUITEM_CLOSEALL = "eu.etaxonomy.taxeditor.application.handledmenuitem.closeAll";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_APPLICATION_HANDLEDMENUITEM_EXIT = "eu.etaxonomy.taxeditor.application.handledmenuitem.exit";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_APPLICATION_HANDLEDMENUITEM_EXPORT = "eu.etaxonomy.taxeditor.application.handledmenuitem.export";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_APPLICATION_HANDLEDMENUITEM_IMPORT = "eu.etaxonomy.taxeditor.application.handledmenuitem.import";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_APPLICATION_HANDLEDMENUITEM_SAVE = "eu.etaxonomy.taxeditor.application.handledmenuitem.save";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_APPLICATION_HANDLEDMENUITEM_SAVEALL = "eu.etaxonomy.taxeditor.application.handledmenuitem.saveAll";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_HANDLEDMENUITEM_COMMANDLABEL17 = "eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel17";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_HANDLEDMENUITEM_COMMANDLABEL19 = "eu.etaxonomy.taxeditor.workbench.handledmenuitem.commandlabel19";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_ADMIN_DBPREFERENCES = "eu.etaxonomy.taxeditor.workbench.menu.admin.dbpreferences";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_ADMIN_DBREPAIR = "eu.etaxonomy.taxeditor.workbench.menu.admin.dbrepair";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_HELP_ABOUT_EDIT = "eu.etaxonomy.taxeditor.workbench.menu.help.about_edit";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_HELP_DYNAMIC = "eu.etaxonomy.taxeditor.workbench.menu.help.dynamic";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_HELP_HELP_CONTENTS = "eu.etaxonomy.taxeditor.workbench.menu.help.help_contents";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_HELP_PARSER = "eu.etaxonomy.taxeditor.workbench.menu.help.parser";
+ public static final String HANDLEDMENUITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_HELP_SEARCH = "eu.etaxonomy.taxeditor.workbench.menu.help.search";
+ public static final String HANDLEDMENUITEM_ORG_ECLIPSE_UI_MAIN_MENU_WINDOW_PREFERENCES = "org.eclipse.ui.main.menu.window.preferences";
+ public static final String HANDLEDTOOLITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_TOOLBAR_NEW = "eu.etaxonomy.taxeditor.workbench.menu.toolbar.new";
+ public static final String HANDLEDTOOLITEM_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_TOOLBAR_SAVE = "eu.etaxonomy.taxeditor.workbench.menu.toolbar.save";
+ public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_HANDLER_OPENDATABASEPREFERENCESWIZARDHANDLER = "eu.etaxonomy.taxeditor.handler.OpenDatabasePreferencesWizardHandler";
+ public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_HANDLER_OPENDATABASEREPAIRWIZARDHANDLER = "eu.etaxonomy.taxeditor.handler.OpenDatabaseRepairWizardHandler";
+ public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_OPENEXTERNALABOUTPLATFORMHANDLER = "eu.etaxonomy.taxeditor.OpenExternalAboutPlatformHandler";
+ public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_OPENEXTERNALPARSERHELPHANDLER = "eu.etaxonomy.taxeditor.OpenExternalParserHelpHandler";
+ public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_UPDATE_INSTALLNEWSOFTWAREHANDLER = "eu.etaxonomy.taxeditor.update.InstallNewSoftwareHandler";
+ public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_UPDATE_UPDATEHANDLER = "eu.etaxonomy.taxeditor.update.UpdateHandler";
+ public static final String HANDLER_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_OPENPARTHANDLER = "eu.etaxonomy.taxeditor.workbench.OpenPartHandler";
+ public static final String MENUCONTRIBUTION_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU = "eu.etaxonomy.taxeditor.workbench.menu";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_APPLICATION_FILEMENU_IO = "eu.etaxonomy.taxeditor.application.filemenu.io";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_APPLICATION_MENUSEPARATOR_0 = "eu.etaxonomy.taxeditor.application.menuseparator.0";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_APPLICATION_MENUSEPARATOR_1 = "eu.etaxonomy.taxeditor.application.menuseparator.1";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_APPLICATION_MENUSEPARATOR_3 = "eu.etaxonomy.taxeditor.application.menuseparator.3";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_APPLICATION_WINDOWMENU_LAST = "eu.etaxonomy.taxeditor.application.windowMenu.last";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENUSEPARATOR_0 = "eu.etaxonomy.taxeditor.workbench.menuseparator.0";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENUSEPARATOR_1 = "eu.etaxonomy.taxeditor.workbench.menuseparator.1";
+ public static final String MENUSEPARATOR_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENUSEPARATOR_2 = "eu.etaxonomy.taxeditor.workbench.menuseparator.2";
+ public static final String MENU_EU_ETAXONOMY_NAVIGATION_MENU_NEW = "eu.etaxonomy.navigation.menu.new";
+ public static final String MENU_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_ADMIN = "eu.etaxonomy.taxeditor.workbench.menu.admin";
+ public static final String MENU_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_EDIT = "eu.etaxonomy.taxeditor.workbench.menu.edit";
+ public static final String MENU_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_FILE = "eu.etaxonomy.taxeditor.workbench.menu.file";
+ public static final String MENU_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_HELP = "eu.etaxonomy.taxeditor.workbench.menu.help";
+ public static final String MENU_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_WINDOW = "eu.etaxonomy.taxeditor.workbench.menu.window";
+ public static final String TOOLBAR_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_MENU_TOOLBAR_0 = "eu.etaxonomy.taxeditor.workbench.menu.toolbar.0";
+ public static final String TRIMCONTRIBUTION_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_TRIMCONTRIBUTION_0 = "eu.etaxonomy.taxeditor.workbench.trimcontribution.0";
+}
\ No newline at end of file
diff --git a/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/OpenPartHandler.java b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/OpenPartHandler.java
new file mode 100644
index 000000000..a9079dbe9
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/OpenPartHandler.java
@@ -0,0 +1,30 @@
+
+package eu.etaxonomy.taxeditor.workbench;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
+
+public class OpenPartHandler {
+
+ @Execute
+ public void execute(ParameterizedCommand commandParameters, EPartService partService) {
+
+ if (null == commandParameters) {
+ return;
+ }
+ Map parameterMap = commandParameters.getParameterMap();
+ String partId = parameterMap.get(AppModelId.COMMANDPARAMETER_EU_ETAXONOMY_TAXEDITOR_WORKBENCH_COMMANDPARAMETER_PARTNAME).toString();
+ partService.showPart(partId, PartState.ACTIVATE);
+ }
+
+ @CanExecute
+ public boolean canExecute() {
+ return true;
+ }
+
+}
\ No newline at end of file
--
2.34.1