From 9a512b18de9b80617fd118c40746dc31db22aa76 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Thu, 9 Mar 2017 15:40:16 +0100
Subject: [PATCH] ref #5923 "Open in.." menu restructuring
- "BulkEditor" option is removed when already in BulkEditor
- "BulkEditor" added for Specimen Editor
---
eu.etaxonomy.taxeditor.bulkeditor/plugin.xml | 13 ++++++++++---
.../command/BulkEditorSelectionPropertyTester.java | 5 +++++
eu.etaxonomy.taxeditor.editor/plugin.xml | 2 +-
.../taxeditor/view/CdmViewerContextMenu.java | 5 +++++
.../eu/etaxonomy/taxeditor/view/CdmViewerUtil.java | 6 ++++++
5 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml b/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
index abb836ab2..0d063eb20 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
@@ -539,9 +539,16 @@
class="eu.etaxonomy.taxeditor.bulkeditor.handler.defaultHandler.OpenBulkEditorForIdentifiableEntity"
commandId="eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity">
-
-
+
+
+
+
+
+
+
+
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
index 1f5b7016e..4a2aee996 100644
--- 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
@@ -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;
}
diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml
index 7e8562a26..5b32eb4b3 100644
--- a/eu.etaxonomy.taxeditor.editor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.editor/plugin.xml
@@ -2027,7 +2027,7 @@
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerContextMenu.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerContextMenu.java
index 18ac555e6..09edf27ac 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerContextMenu.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerContextMenu.java
@@ -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$
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
index 729b513f1..04fe5cf4a 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerUtil.java
@@ -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();
--
2.34.1