From 0800831bc0403bd2c06f9ade95e4864f8a5a2779 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Wed, 30 Jan 2019 08:28:24 +0100
Subject: [PATCH] ref #6806 Disable export context menu for feature nodes
---
eu.etaxonomy.taxeditor.store/fragment.e4xmi | 1 +
eu.etaxonomy.taxeditor.store/plugin.xml | 16 ++++++
.../FeatureTreePropertyTester.java | 50 +++++++++++++++++++
3 files changed, 67 insertions(+)
create mode 100644 eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/FeatureTreePropertyTester.java
diff --git a/eu.etaxonomy.taxeditor.store/fragment.e4xmi b/eu.etaxonomy.taxeditor.store/fragment.e4xmi
index ec32a996b..907b66c8d 100644
--- a/eu.etaxonomy.taxeditor.store/fragment.e4xmi
+++ b/eu.etaxonomy.taxeditor.store/fragment.e4xmi
@@ -24,6 +24,7 @@
+
diff --git a/eu.etaxonomy.taxeditor.store/plugin.xml b/eu.etaxonomy.taxeditor.store/plugin.xml
index f2989764a..48160be9f 100755
--- a/eu.etaxonomy.taxeditor.store/plugin.xml
+++ b/eu.etaxonomy.taxeditor.store/plugin.xml
@@ -117,6 +117,13 @@
properties="hasPermissions, hasRoles"
type="org.eclipse.jface.viewers.IStructuredSelection">
+
+
@@ -258,6 +265,15 @@
property="eu.etaxonomy.taxeditor.preference.PreferencePropertyTester.isChecklistEditorEnabled">
+
+
+
+
+
+
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/FeatureTreePropertyTester.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/FeatureTreePropertyTester.java
new file mode 100644
index 000000000..40b8fa209
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/FeatureTreePropertyTester.java
@@ -0,0 +1,50 @@
+/**
+ *
+ */
+package eu.etaxonomy.taxeditor.featuretree;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.cdm.model.description.FeatureTree;
+
+/**
+ * Property tester used by the feature tree menu.
+ *
+ * @author pplitzner
+ * @since Jan 30, 2019
+ *
+ */
+public class FeatureTreePropertyTester extends PropertyTester {
+
+ private static final String FEATURE_TREE= "isFeatureTree"; //$NON-NLS-1$
+
+ @Override
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue) {
+
+ Object[] selectedElements = ((IStructuredSelection) receiver).toArray();
+
+ if(selectedElements.length == 0){
+ // nothing selected so all tests should fail
+ return false;
+ }
+
+ if(FEATURE_TREE.equals(property)){
+ return isFeatureTree(selectedElements);
+ }
+ else{
+ return false;
+ }
+ }
+
+ private boolean isFeatureTree(Object[] selectedElements) {
+ for (Object object : selectedElements){
+ if(!(object instanceof FeatureTree)){
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
--
2.34.1