fix #5988 Add Checklist Editor to generic "Open in..." menu
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 18 Aug 2016 13:10:55 +0000 (15:10 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 18 Aug 2016 13:11:18 +0000 (15:11 +0200)
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java
eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle.properties
eu.etaxonomy.taxeditor.navigation/OSGI-INF/l10n/bundle_de.properties
eu.etaxonomy.taxeditor.navigation/plugin.xml

index e3f0fba1cf1b1be50e33e8337355f841447d14dc..ef403bd00952ba75760215a1fb45cd006d81b7d3 100644 (file)
@@ -184,3 +184,4 @@ command.name.TOGGLE_LINK_WITH_TAXON_SELECTION = Toggle link with taxon selection
 \r
 viewCommandMapping.viewerName.NAME_EDITOR = Name Editor\r
 viewCommandMapping.viewerName.SPECIMEN_EDITOR = Derivative Editor\r
+viewCommandMapping.viewerName.CHECKLIST_EDITOR = Checklist Editor
\ No newline at end of file
index 8c3d36882a4badb1fb468032366e0f19258aa480..ace0d93b8b243d4945dbb2084066e11d356b9ec4 100644 (file)
@@ -182,4 +182,5 @@ command.name.REMOVE_SINGLE_READ = Entferne Single-Read von Sequenz
 command.name.TOGGLE_LINK_WITH_TAXON_SELECTION = De-/Aktiviere Verknüpfung mit Taxonauswahl
 
 viewCommandMapping.viewerName.NAME_EDITOR = Namenseditor
-viewCommandMapping.viewerName.SPECIMEN_EDITOR = Specimen-Editor
\ No newline at end of file
+viewCommandMapping.viewerName.SPECIMEN_EDITOR = Specimen-Editor
+viewCommandMapping.viewerName.CHECKLIST_EDITOR = Checklisten-Editor
\ No newline at end of file
index ff295745290b3980ac2596f3f89fa39cfdfdccbd..0bb691ff25cab3f3fe257f41f159fa93d724f4ee 100644 (file)
             </with>
          </activeWhen>
       </handler>
-      <handler
-            class="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler"
-            commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler">
-      </handler>
       <handler
             class="eu.etaxonomy.taxeditor.editor.view.derivate.handler.DeleteDerivateHandler"
             commandId="org.eclipse.ui.edit.delete">
             </with>
          </activeWhen>
       </handler>
+      <handler
+            class="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler"
+            commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler">
+         <activeWhen>
+            <and>
+               <reference
+                     definitionId="isChecklistEditorEnabled">
+               </reference>
+               <or>
+                  <reference
+                        definitionId="isTaxonNode">
+                  </reference>
+                  <reference
+                        definitionId="isClassification">
+                  </reference>
+               </or>
+            </and>
+         </activeWhen>
+      </handler>
    </extension>
    <extension
          name="%extension.name"
             name="%command.name.34">
       </command>
        <command
-             defaultHandler="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistEditorHandler"
              id="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
              name="%command.name.38">
+          <commandParameter
+                id="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler.uuid"
+                name="taxonNodeUuid"
+                optional="true"
+                typeId="eu.etaxonomy.taxeditor.uuidParameterType">
+          </commandParameter>
        </command>
       <command
             categoryId="eu.etaxonomy.taxeditor.editor.new.category"
             selection="eu.etaxonomy.cdm.model.taxon.TaxonNode"
             viewerName="%viewCommandMapping.viewerName.SPECIMEN_EDITOR">
       </viewCommandMapping>
+      <viewCommandMapping
+            commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
+            selection="eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode"
+            viewerName="%viewCommandMapping.viewerName.CHECKLIST_EDITOR">
+      </viewCommandMapping>
     </extension>
 </plugin>
index cc2bbf04772df20c8212f1eb3fe2287dca68d3ad..0b16c16c806ab279b8dd5f6068983c3ff917166c 100644 (file)
@@ -1,65 +1,58 @@
 package eu.etaxonomy.taxeditor.editor.handler;
 
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
+import java.util.UUID;
+
 import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
 
+import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.handler.defaultHandler.DefaultOpenHandlerBase;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 
-public class OpenChecklistEditorHandler extends AbstractHandler {
+public class OpenChecklistEditorHandler extends DefaultOpenHandlerBase<ITaxonTreeNode> {
 
-    private static final Logger logger = Logger.getLogger(OpenChecklistEditorHandler.class);
+       @Override
+       protected ITaxonTreeNode getEntity(UUID uuid) {
+               ITaxonTreeNode taxonTreeNode = CdmStore.getService(ITaxonNodeService.class).load(uuid);
+               if(taxonTreeNode==null){
+                       taxonTreeNode = CdmStore.getService(IClassificationService.class).load(uuid);
+               }
+               return taxonTreeNode;
+       }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
-     * ExecutionEvent)
-     */
-    @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-        boolean isChecklistEditorActivated = PreferencesUtil.getPreferenceStore().getBoolean(
-                IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
-        if (isChecklistEditorActivated) {
-            ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
-            if (currentSelection instanceof IStructuredSelection) {
-                Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
-                if (selectedElement instanceof Classification) {
-                    ChecklistEditorInput input = new ChecklistEditorInput(((Classification) selectedElement));
-                    try {
-                        EditorUtil.open(input);
-                    } catch (PartInitException e) {
-                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
-                    } catch (NullPointerException npe) {
-                       MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
-                                "Could not open ChecklistView. The hierarchy is corrupted!", npe);
-                    }
-                } else if (selectedElement instanceof TaxonNode) {
-                    ChecklistEditorInput input = new ChecklistEditorInput(((TaxonNode) selectedElement));
-                    try {
-                        EditorUtil.open(input);
-                    } catch (PartInitException e) {
-                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
-                    } catch (NullPointerException npe) {
-                       MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
-                                "Could not open ChecklistView. The hierarchy is corrupted!", npe);
-                    }
-                }
-            }
-        }
-        return null;
-    }
+       @Override
+       protected void open(ExecutionEvent event, ITaxonTreeNode entity) {
+               if (PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE)) {
+                       if (entity instanceof Classification) {
+                               ChecklistEditorInput input = new ChecklistEditorInput(((Classification) entity));
+                               try {
+                                       EditorUtil.open(input);
+                               } catch (PartInitException e) {
+                                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
+                               } catch (NullPointerException npe) {
+                                       MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
+                                                       "Could not open ChecklistView. The hierarchy is corrupted!", npe);
+                               }
+                       } else if (entity instanceof TaxonNode) {
+                               ChecklistEditorInput input = new ChecklistEditorInput((TaxonNode) entity);
+                               try {
+                                       EditorUtil.open(input);
+                               } catch (PartInitException e) {
+                                       MessagingUtils.error(OpenChecklistEditorHandler.class, "Could not open ChecklistView", e);
+                               } catch (NullPointerException npe) {
+                                       MessagingUtils.messageDialog("Failed to open Editor", OpenChecklistEditorHandler.class,
+                                                       "Could not open ChecklistView. The hierarchy is corrupted!", npe);
+                               }
+                       }
+               }               
+       }
 }
index e6582f7fdca4d5a3d50b9af91e5472f112a09343..1bb4af14f507c23070787c7567a957cb1d5548b1 100644 (file)
@@ -8,7 +8,6 @@ command.label.1 = Edit
 menu.label = New\r
 command.label.2 = Taxon\r
 command.label.3 = Classification\r
-command.label.4 = Open in Checklist Editor\r
 command.label.5 = Edit\r
 command.label.6 = Change accepted taxon to synonym\r
 command.label.7 = Move taxon (with child taxa)\r
index a561d9e4305e37a7cc897676ee8a1041cde7f9db..f78b7e12dbfb6e9dd219446903087a95693bc874 100644 (file)
@@ -8,7 +8,6 @@ command.label.1 = Bearbeiten
 menu.label = Neu\r
 command.label.2 = Taxon\r
 command.label.3 = Klassifikation\r
-command.label.4 = \u00D6ffne im Checklisten Editor\r
 command.label.5 = Bearbeiten\r
 command.label.6 = Akzeptiertes Taxon zum Synonym umwandeln\r
 command.label.7 = Verschiebe Taxon (mit Kindern)\r
index 2173e1efe33bd9235e25d3619df912e2b74173f8..4960a059f3435d952802d628b4f0bb5586c5bc5b 100644 (file)
                </reference>
             </visibleWhen>
          </menu>
-         <command
-               commandId="eu.etaxonomy.taxeditor.editor.handler.OpenChecklistViewHandler"
-               icon="icons/check.png"
-               label="%command.label.4"
-               style="push">
-           <visibleWhen
-                 checkEnabled="true">
-              <and>
-                 <reference
-                       definitionId="isChecklistEditorEnabled">
-                 </reference>
-                 <or>
-                    <reference
-                          definitionId="isClassification">
-                    </reference>
-                    <reference
-                          definitionId="isTaxonNode">
-                    </reference>
-                 </or>
-              </and>
-            </visibleWhen>
-         </command>
          <command
                commandId="eu.etaxonomy.taxeditor.navigation.navigator.handler.OpenFixClassificationHierarchyHandler"
                label="%command.label.fixClassificationHierarchy"