ref #5923 "Open in.." menu restructuring
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 9 Mar 2017 14:40:16 +0000 (15:40 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 9 Mar 2017 14:40:30 +0000 (15:40 +0100)
 - "BulkEditor" option is removed when already in BulkEditor
 - "BulkEditor" added for Specimen Editor

eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorSelectionPropertyTester.java
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerContextMenu.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java

index abb836ab25513f66bc7336c174c9927424507af9..0d063eb20cdc44156a08037de6beccd5455c3edb 100644 (file)
             class="eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler.OpenBulkEditorForIdentifiableEntity"
             commandId="eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity">
          <activeWhen>
-            <reference
-                  definitionId="isBulkEditorSupported">
-            </reference>
+            <and>
+               <reference
+                     definitionId="isBulkEditorSupported">
+               </reference>
+               <not>
+                  <reference
+                        definitionId="isBulkEditor">
+                  </reference>
+               </not>
+            </and>
          </activeWhen>
       </handler>
       
index 1f5b7016e22cf166d0f81cb9babacf60f38c65e7..4a2aee996d6e799100586f37d4c5f05fc874f1bf 100644 (file)
@@ -2,6 +2,7 @@ package eu.etaxonomy.taxeditor.bulkeditor.command;
 
 import org.eclipse.core.expressions.PropertyTester;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeNode;
 
 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
 import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputType;
@@ -20,6 +21,10 @@ public class BulkEditorSelectionPropertyTester extends PropertyTester {
                                if(selectedElement!=null){
                                    if(selectedElement instanceof UuidAndTitleCache){
                                        return BulkEditorInputType.getByType(((UuidAndTitleCache) selectedElement).getType())!=null;
+                                   }
+                                   else if(selectedElement instanceof TreeNode){
+                                       System.out.println(BulkEditorInputType.getByType(((TreeNode) selectedElement).getValue().getClass())!=null);
+                                       return BulkEditorInputType.getByType(((TreeNode) selectedElement).getValue().getClass())!=null;
                                    }
                                        return BulkEditorInputType.getByType(selectedElement.getClass())!=null;
                                }
index 7e8562a2617b734e90fb09e3b4f505d3b8b0c89c..5b32eb4b382871c559837506a5f43c62f0ce76bd 100644 (file)
       </propertyTester>
       <propertyTester
             class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DescriptionsMenuPropertyTester"
-            id="eu.etaxonomy.taxeditor.descriptions.PropertyTester"
+            id="eu.etaxonomy.taxeditor.descriptions.propertyTester"
             namespace="eu.etaxonomy.taxeditor.descriptions.propertyTester"
             properties="isMedia,isDescription,isDescriptionElement,isDeletable,isFeatureNodeContainer,isImageGallery,isTaxonEditor,isBulkEditor,isDerivateEditor, isIndividualsAssociation"
             type="org.eclipse.jface.viewers.TreeSelection">
index 18ac555e67a1e21096f86e337f436ccb272cb45b..09edf27acceb7a3cba2e134461b5419bc6c398a4 100644 (file)
@@ -12,6 +12,7 @@ import org.eclipse.jface.action.ContributionItem;
 import org.eclipse.jface.action.IContributionItem;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -100,6 +101,10 @@ public class CdmViewerContextMenu extends CompoundContributionItem {
             if (selectedObject instanceof UuidAndTitleCache){
                 selectedObject = CdmStore.getCommonService().find(CdmBase.class, ((UuidAndTitleCache)selectedObject).getUuid());
             }
+            //for tree nodes get the value resp. the object of the node
+            else if (selectedObject instanceof TreeNode){
+                selectedObject = ((TreeNode) selectedObject).getValue();
+            }
             if(selectedObject instanceof ICdmBase){
                 params.put(command.getId()+".uuid", ((ICdmBase) selectedObject).getUuid()); //$NON-NLS-1$
             }
index 729b513f1c2a65dcfd6e1e2f31efb3e6ec11b2ce..04fe5cf4afdb4a73daffcbb75cccdca2a4da3023 100644 (file)
@@ -15,6 +15,7 @@ import org.eclipse.core.commands.Command;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.commands.ICommandService;
 
@@ -48,6 +49,11 @@ public class CdmViewerUtil {
                 UuidAndTitleCache uuidAndTitleCache = (UuidAndTitleCache)input;
                 input = CdmStore.getCommonService().find(uuidAndTitleCache.getType(), uuidAndTitleCache.getUuid());
             }
+            //for tree nodes get the value resp. the object of the node
+            else if (input instanceof TreeNode){
+                TreeNode treeNode = (TreeNode)input;
+                input = treeNode.getValue();
+            }
 
 
             IExtensionRegistry reg = Platform.getExtensionRegistry();