fix #6062 Add property tester for "Open in..." bulk editor menu items
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 14 Sep 2016 05:10:18 +0000 (07:10 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 14 Sep 2016 05:11:07 +0000 (07:11 +0200)
 - moved isGroupEditor property test to bulk editor plugin

eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorSelectionPropertyTester.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/plugin.xml

index 6570a9cb40edd7dc02dbcebcee9481cf023e1a0b..abb836ab25513f66bc7336c174c9927424507af9 100644 (file)
             name="%command.name.OPEN_BULK_EDITOR_FOR_TAXON_NODE">
       </command>
       <command
-            defaultHandler="eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler.OpenBulkEditorForIdentifiableEntity"
             id="eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity"
             name="Open bulk editor for identifiable entity">
          <commandParameter
             </test>
          </with>
       </definition>
+      <definition
+            id="isBulkEditorSupported">
+         <with
+               variable="selection">
+            <test
+                  property="eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorSelectionPropertyTester.isBulkEditorSupported">
+            </test>
+         </with>
+      </definition>
+      <definition
+            id="isGroupEditor">
+         <with
+               variable="activeEditor">
+            <test
+                  property="taxeditor-bulkeditor.propertyTester.isGroupEditor">
+            </test>
+         </with>
+      </definition>
    </extension>
    <extension
          point="org.eclipse.core.expressions.propertyTesters">
             properties="isTeam, isPerson"
             type="java.lang.Object">
       </propertyTester>
+      <propertyTester
+            class="eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorSelectionPropertyTester"
+            id="eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorSelectionPropertyTester"
+            namespace="eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorSelectionPropertyTester"
+            properties="isBulkEditorSupported"
+            type="org.eclipse.jface.viewers.IStructuredSelection">
+      </propertyTester>
    </extension>
    <extension
          point="org.eclipse.ui.handlers">
             class="eu.etaxonomy.taxeditor.bulkeditor.handler.ConvertPerson2TeamHandler"
             commandId="eu.etaxonomy.taxeditor.bulkeditor.convertPerson2Team">
       </handler>
+      <handler
+            class="eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler.OpenBulkEditorForIdentifiableEntity"
+            commandId="eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity">
+         <activeWhen>
+            <reference
+                  definitionId="isBulkEditorSupported">
+            </reference>
+         </activeWhen>
+      </handler>
       
    </extension>
    <extension
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorSelectionPropertyTester.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorSelectionPropertyTester.java
new file mode 100644 (file)
index 0000000..8c544a7
--- /dev/null
@@ -0,0 +1,27 @@
+package eu.etaxonomy.taxeditor.bulkeditor.command;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
+
+public class BulkEditorSelectionPropertyTester extends PropertyTester {
+
+    public static final String IS_BULK_EDITOR_SUPPORTED = "isBulkEditorSupported";
+    
+       @Override
+       public boolean test(Object receiver, String property, Object[] args,
+                       Object expectedValue) {
+               if(IS_BULK_EDITOR_SUPPORTED.equals(property)){
+                       if(receiver instanceof IStructuredSelection){
+                               IStructuredSelection selection = (IStructuredSelection) receiver;
+                               Object selectedElement = selection.getFirstElement();
+                               if(selectedElement!=null){
+                                       return BulkEditorInputType.getByType(selectedElement.getClass())!=null;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+}
index e32835fb70b94aeb9508fc8cef3f9248956f172a..d44bd77183832366df05898333172c42d3cb6315 100644 (file)
             </test>
          </with>
       </definition>
-      <definition
-            id="isGroupEditor">
-         <with
-               variable="activeEditor">
-            <test
-                  property="taxeditor-bulkeditor.propertyTester.isGroupEditor">
-            </test>
-         </with>
-      </definition>
       <definition
             id="isIndividualsAssociation">
          <with
             properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor,isBulkEditor,isDerivateEditor, isIndividualsAssociation"
             type="org.eclipse.jface.viewers.TreeSelection">
       </propertyTester>
-      <propertyTester
-            class="eu.etaxonomy.taxeditor.bulkeditor.command.BulkEditorPropertyTester"
-            id="taxeditor-bulkeditor.PropertyTester"
-            namespace="taxeditor-bulkeditor.propertyTester"
-            properties="isGroupEditor"
-            type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor">
-      </propertyTester>
       <propertyTester
             class="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester"
             id="eu.etaxonomy.taxeditor.editor.handler.SpecimenPropertyTester"