Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2014-07-07 14:55:14 -0400
committerBob Brodt2014-07-07 14:55:14 -0400
commit0446a989245c7e079522d3fa21b6109371efda56 (patch)
treea8d03fc6401b322076a51461419114fd2ca43630
parent804f2cc1a683c4a1668c8585b60499d289c70ec0 (diff)
downloadorg.eclipse.bpmn2-modeler-0446a989245c7e079522d3fa21b6109371efda56.tar.gz
org.eclipse.bpmn2-modeler-0446a989245c7e079522d3fa21b6109371efda56.tar.xz
org.eclipse.bpmn2-modeler-0446a989245c7e079522d3fa21b6109371efda56.zip
Fix Tool Enablement preferences.
-rw-r--r--examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/plugin.xml2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CustomElementFeatureContainer.java11
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java92
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ModelEnablements.java25
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/BaseRuntimeExtensionDescriptor.java4
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/ModelExtensionDescriptor.java19
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java105
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencePage.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencesHelper.java138
9 files changed, 233 insertions, 165 deletions
diff --git a/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/plugin.xml b/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/plugin.xml
index 4ead7a0f..f2eff3d3 100644
--- a/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/plugin.xml
+++ b/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/plugin.xml
@@ -72,8 +72,8 @@
icon="mitigation.png"
runtimeId="org.eclipse.bpmn2.modeler.examples.dynamic"
type="TextAnnotation">
- <property name="text" value="Mitigation Task" type="EString"/>
<property name="name" value="Mitigation Task" type="EString"/>
+ <property name="text" value="Mitigation Task" type="EString"/>
<property name="evaluate" value="true" type="EBoolean" description="Include this activity in Risk Calculations"/>
<property name="benefit" value="0" type="EInt" description="Potential benefit provided by this Mitigation activity"/>
</customTask>
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CustomElementFeatureContainer.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CustomElementFeatureContainer.java
index 3ecaa202..f67b35b3 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CustomElementFeatureContainer.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/CustomElementFeatureContainer.java
@@ -12,11 +12,11 @@ package org.eclipse.bpmn2.modeler.core.features;
import org.eclipse.bpmn2.BaseElement;
import org.eclipse.bpmn2.modeler.core.model.ModelDecorator;
+import org.eclipse.bpmn2.modeler.core.preferences.ModelEnablements;
import org.eclipse.bpmn2.modeler.core.runtime.CustomTaskDescriptor;
import org.eclipse.bpmn2.modeler.core.runtime.CustomTaskImageProvider;
import org.eclipse.bpmn2.modeler.core.runtime.TargetRuntime;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
-import org.eclipse.bpmn2.modeler.core.features.Messages;
import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
@@ -39,6 +39,8 @@ import org.eclipse.graphiti.mm.algorithms.Image;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.ui.editor.DiagramEditor;
+import org.eclipse.ocl.util.Adaptable;
/**
* The base class for custom shape and connection Feature Containers.
@@ -132,6 +134,13 @@ public class CustomElementFeatureContainer implements ICustomElementFeatureConta
*/
@Override
public boolean isAvailable(IFeatureProvider fp) {
+ DiagramEditor editor = (DiagramEditor) fp.getDiagramTypeProvider().getDiagramEditor();
+ if (editor != null) {
+ ModelEnablements me = (ModelEnablements)editor.getAdapter(ModelEnablements.class);
+ if (me!=null) {
+ return me.isEnabled(customTaskDescriptor.getType());
+ }
+ }
return true;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java
index 1cba1e4a..cb6f803f 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/Bpmn2Preferences.java
@@ -47,6 +47,7 @@ import org.eclipse.bpmn2.di.BPMNShape;
import org.eclipse.bpmn2.modeler.core.Activator;
import org.eclipse.bpmn2.modeler.core.adapters.ObjectPropertyProvider;
import org.eclipse.bpmn2.modeler.core.runtime.ModelEnablementDescriptor;
+import org.eclipse.bpmn2.modeler.core.runtime.ModelExtensionDescriptor;
import org.eclipse.bpmn2.modeler.core.runtime.TargetRuntime;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -67,7 +68,9 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChange
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -386,11 +389,33 @@ public class Bpmn2Preferences implements IResourceChangeListener, IPropertyChang
}
else if (key.equals(PREF_MODEL_ENABLEMENT)) {
for (TargetRuntime rt : TargetRuntime.createTargetRuntimes()) {
- for (ModelEnablementDescriptor med : rt.getModelEnablements()) {
- String path = getModelEnablementsPath(rt, med.getId());
+ if (rt.getModelEnablements().size()==0) {
+ String path = getModelEnablementsPath(rt, null);
Preferences prefs = defaultPreferences.node(path);
- for (String s : med.getAllEnabled()) {
+ for (Entry<EClass, List<EStructuralFeature>> e : rt.getModelExtensions(0).entrySet()) {
+ for (EStructuralFeature f : e.getValue()) {
+ String s = e.getKey().getName() + "." + f.getName();
+ prefs.putBoolean(s, Boolean.TRUE);
+ }
+ }
+ ModelEnablements me = new ModelEnablements(rt,"default");
+ me.setEnabledAll(true);
+ for (String s : me.getAllEnabled())
prefs.putBoolean(s, Boolean.TRUE);
+ }
+ else {
+ for (ModelEnablementDescriptor med : rt.getModelEnablements()) {
+ String path = getModelEnablementsPath(rt, med.getId());
+ Preferences prefs = defaultPreferences.node(path);
+ for (String s : med.getAllEnabled()) {
+ prefs.putBoolean(s, Boolean.TRUE);
+ }
+ for (Entry<EClass, List<EStructuralFeature>> e : rt.getModelExtensions(0).entrySet()) {
+ for (EStructuralFeature f : e.getValue()) {
+ String s = e.getKey().getName() + "." + f.getName();
+ prefs.putBoolean(s, Boolean.TRUE);
+ }
+ }
}
}
}
@@ -848,6 +873,8 @@ public class Bpmn2Preferences implements IResourceChangeListener, IPropertyChang
////////////////////////////////////////////////////////////////////////////////
public static String getModelEnablementsPath(TargetRuntime rt, String profileId) {
+ if (profileId==null || profileId.isEmpty())
+ profileId = "default";
return PREF_MODEL_ENABLEMENT + "/" + rt.getId() + "/" + profileId; //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -857,44 +884,39 @@ public class Bpmn2Preferences implements IResourceChangeListener, IPropertyChang
public ModelEnablements getModelEnablements(TargetRuntime rt, String profileId) {
ModelEnablements me = new ModelEnablements(rt, profileId);
- if (profileId!=null && !profileId.isEmpty()) {
- try {
- Preferences prefs = null;
- String path = getModelEnablementsPath(rt, profileId);
- if (projectPreferences!=null && projectPreferences.nodeExists(path))
- prefs = projectPreferences.node(path);
- else if (instancePreferences.nodeExists(path))
- prefs = instancePreferences.node(path);
- else if (defaultPreferences.nodeExists(path))
- prefs = defaultPreferences.node(path);
-
- if (prefs!=null) {
- boolean create = false;
- ModelEnablementDescriptor med = rt.getModelEnablements(profileId);
- if (med==null) {
- String profileName = prefs.get("name","Unnamed Profile");
- String description = prefs.get("description","");
- med = createToolProfile(rt, profileId, profileName, description);
- create = true;
- }
+ try {
+ Preferences prefs = null;
+ String path = getModelEnablementsPath(rt, profileId);
+ if (projectPreferences!=null && projectPreferences.nodeExists(path))
+ prefs = projectPreferences.node(path);
+ else if (instancePreferences.nodeExists(path))
+ prefs = instancePreferences.node(path);
+ else if (defaultPreferences.nodeExists(path))
+ prefs = defaultPreferences.node(path);
+
+ if (prefs!=null) {
+ boolean create = false;
+ ModelEnablementDescriptor med = rt.getModelEnablements(profileId);
+ if (med==null) {
+ String profileName = prefs.get("name","Unnamed Profile");
+ String description = prefs.get("description","");
+ med = createToolProfile(rt, profileId, profileName, description);
+ create = true;
+ }
- me.setEnabledAll(false);
- for (String k : prefs.keys()) {
- if (prefs.getBoolean(k, false)) {
- me.setEnabled(k, true);
- if (create) {
- med.setEnabled(k, true);
- }
+ me.setEnabledAll(false);
+ for (String k : prefs.keys()) {
+ if (prefs.getBoolean(k, false)) {
+ me.setEnabled(k, true);
+ if (create) {
+ med.setEnabled(k, true);
}
}
}
}
- catch (BackingStoreException e) {
- e.printStackTrace();
- }
}
- else {
- me.setEnabledAll(true);
+ catch (BackingStoreException e) {
+ e.printStackTrace();
}
return me;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ModelEnablements.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ModelEnablements.java
index 59468767..1a1694a8 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ModelEnablements.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/preferences/ModelEnablements.java
@@ -365,7 +365,6 @@ public class ModelEnablements {
if (className==null)
return true;
-
if (classes.containsKey(className)) { // && isOverride()) {
if (featureName!=null && !featureName.isEmpty()) {
// the "anyAttribute" FeatureMap should always be enabled,
@@ -393,38 +392,14 @@ public class ModelEnablements {
}
}
}
- if (isEnabled(targetRuntime, className, featureName))
- return true;
return false;
}
return true;
}
-
- // Check any model extensions - these are always enabled by default
- // This is an expensive operation, so we'll cache these values.
- //
- // FIXME: if there ever comes a time when we'll want to reload model extensions
- // while the editor is still active, we'll need to clear out this cache.
- if (isEnabled(targetRuntime, className, featureName))
- return true;
-
- // FIXME: should we also check the Default Target Runtime extensions?
-// if (targetRuntime!=TargetRuntime.getDefaultRuntime())
-// return isEnabled(TargetRuntime.getDefaultRuntime(), className, featureName);
return false;
}
- private boolean isEnabled(TargetRuntime targetRuntime, String className, String featureName) {
- for (ModelExtensionDescriptor md : targetRuntime.getAllModelExtensionDescriptors()) {
- if (md.isDefined(className, featureName)) {
- setEnabled(className, featureName, true);
- return true;
- }
- }
- return false;
- }
-
public boolean isEnabled(EClass eClass, EStructuralFeature feature) {
if (feature==null)
return isEnabled(eClass);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/BaseRuntimeExtensionDescriptor.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/BaseRuntimeExtensionDescriptor.java
index 08d87808..ac131279 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/BaseRuntimeExtensionDescriptor.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/BaseRuntimeExtensionDescriptor.java
@@ -145,9 +145,9 @@ public abstract class BaseRuntimeExtensionDescriptor implements IRuntimeExtensio
}
public EClassifier getClassifier(String name) {
- EClass eClass = (EClass)getEPackage().getEClassifier(name);
+ EClassifier eClass = getEPackage().getEClassifier(name);
if (eClass==null) {
- eClass = (EClass)Bpmn2Package.eINSTANCE.getEClassifier(name);
+ eClass = Bpmn2Package.eINSTANCE.getEClassifier(name);
}
return eClass;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/ModelExtensionDescriptor.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/ModelExtensionDescriptor.java
index 7627c3ac..8655bbe8 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/ModelExtensionDescriptor.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/ModelExtensionDescriptor.java
@@ -501,9 +501,14 @@ public class ModelExtensionDescriptor extends BaseRuntimeExtensionDescriptor {
return object.eGet(feature);
}
- // FIXME: this is called in ToolProfilesPreferencesHelper. Check if there's a way to decouple.
- public EStructuralFeature getFeature(EObject object, Property property) {
- EClass eClass = object.eClass();
+ public EClass createEClass(String type) {
+ EClass eClass = getModelDecorator().getEClass(type);
+ if (eClass==null)
+ eClass = getModelDecorator().createEClass(type);
+ return eClass;
+ }
+
+ public EStructuralFeature createEFeature(EClass eClass, Property property) {
EStructuralFeature feature = eClass.getEStructuralFeature(property.name);
boolean isAttribute = true;
@@ -524,7 +529,7 @@ public class ModelExtensionDescriptor extends BaseRuntimeExtensionDescriptor {
if (isAttribute) {
if (feature==null)
- feature = modelDecorator.createEAttribute(
+ feature = getModelDecorator().createEAttribute(
property.name,
property.type,
eClass.getName(),
@@ -532,7 +537,7 @@ public class ModelExtensionDescriptor extends BaseRuntimeExtensionDescriptor {
}
else {
if (feature==null)
- feature = modelDecorator.createEReference(
+ feature = getModelDecorator().createEReference(
property.name,
property.type,
eClass.getName(),
@@ -544,6 +549,10 @@ public class ModelExtensionDescriptor extends BaseRuntimeExtensionDescriptor {
return feature;
}
+
+ private EStructuralFeature getFeature(EObject object, Property property) {
+ return createEFeature(object.eClass(), property);
+ }
/**
* Populate the given EObject from the Property tree defined in this runtime
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java
index 643b946c..ffafa9b9 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/runtime/TargetRuntime.java
@@ -18,13 +18,17 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.bpmn2.Bpmn2Package;
import org.eclipse.bpmn2.modeler.core.IBpmn2RuntimeExtension;
import org.eclipse.bpmn2.modeler.core.LifecycleEvent;
import org.eclipse.bpmn2.modeler.core.model.Bpmn2ModelerResourceImpl;
+import org.eclipse.bpmn2.modeler.core.model.ModelDecorator;
import org.eclipse.bpmn2.modeler.core.preferences.ShapeStyle;
+import org.eclipse.bpmn2.modeler.core.runtime.ModelExtensionDescriptor.Property;
import org.eclipse.bpmn2.modeler.core.utils.ErrorDialog;
import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.core.resources.IFile;
@@ -33,7 +37,9 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.graphiti.ui.editor.DiagramEditor;
@@ -868,6 +874,105 @@ public class TargetRuntime extends BaseRuntimeExtensionDescriptor implements IRu
return null;
}
+ /**
+ * Returns a list of model extension types and their features. A filter can
+ * be used to select only BPMN2 model elements, plugin model elements or
+ * both.
+ *
+ * @param filter selects which elements to return: 0 = all, 1 = BPMN2 model
+ * extensions only, 2 = plugin model extension elements only
+ * @return a list of EClass objects, and their lists of EStructuralFeatures.
+ */
+ public Hashtable<EClass, List<EStructuralFeature>> getModelExtensions(int filter) {
+ Hashtable<EClass, List<EStructuralFeature>> list = new Hashtable<EClass, List<EStructuralFeature>>();
+ for (CustomTaskDescriptor ctd : getCustomTaskDescriptors()) {
+ getModelExtensions(filter, ctd, list);
+ }
+ for (ModelExtensionDescriptor med : getModelExtensionDescriptors()) {
+ getModelExtensions(filter, med, list);
+ }
+ if (filter==2) { // plugin extension elements only
+ ModelDescriptor md = getModelDescriptor();
+ if (md.getEPackage() != Bpmn2Package.eINSTANCE) {
+ for (EClassifier ec : md.getEPackage().getEClassifiers()) {
+ if (ec.getName().equals("DocumentRoot"))
+ continue;
+ if (ec instanceof EClass) {
+ EClass eClass = (EClass)ec;
+ List<EStructuralFeature> features = list.get(eClass);
+ if (features==null) {
+ features = new ArrayList<EStructuralFeature>();
+ list.put(eClass,features);
+ }
+ for (EStructuralFeature f : eClass.getEStructuralFeatures()) {
+ features.add(f);
+ }
+ }
+ }
+ }
+ }
+ return list;
+ }
+
+ private void getModelExtensions(int filter, ModelExtensionDescriptor med, Hashtable<EClass, List<EStructuralFeature>> list) {
+ String type = med.getType();
+ EClassifier bpmn2type = Bpmn2Package.eINSTANCE.getEClassifier(type);
+ if (filter==1) { // BPMN2 elements only
+ if (bpmn2type==null)
+ return;
+ }
+ if (filter==2) { // plugin extension elements only
+ if (bpmn2type!=null)
+ return;
+ }
+ EClass eClass = med.createEClass(type);
+ List<EStructuralFeature> features = list.get(eClass);
+ if (features==null) {
+ features = new ArrayList<EStructuralFeature>();
+ list.put(eClass,features);
+ }
+ for (Property p : med.getProperties()) {
+ EStructuralFeature feature = med.createEFeature(eClass, p);
+ if (bpmn2type instanceof EClass) {
+ // ignore structural features that are already defined in
+ // the BPMN2 package. These <property> elements are used
+ // only for initialization of these features and should not
+ // be considered as model extensions.
+ if (((EClass) bpmn2type).getEStructuralFeature(p.name)!=null)
+ continue;
+ }
+ if (feature!=null && !features.contains(feature))
+ features.add(feature);
+ for (Object v : p.getValues()) {
+ if (v instanceof Property) {
+ getModelExtensions(med, (Property)v, list);
+ }
+ }
+ }
+ if (features.isEmpty())
+ list.remove(eClass);
+ }
+
+ private void getModelExtensions(ModelExtensionDescriptor med, Property p, Hashtable<EClass, List<EStructuralFeature>> list) {
+ EClassifier eClassifier = med.getClassifier(p.name);
+ if (eClassifier instanceof EClass) {
+ EClass eClass = (EClass) eClassifier;
+ List<EStructuralFeature> features = list.get(eClass);
+ if (features==null) {
+ features = new ArrayList<EStructuralFeature>();
+ list.put(eClass,features);
+ }
+ for (Object v : p.getValues()) {
+ if (v instanceof Property) {
+ EStructuralFeature feature = med.createEFeature(eClass, (Property)v);
+ if (feature!=null && !features.contains(feature))
+ features.add(feature);
+ getModelExtensions(med, (Property)v, list);
+ }
+ }
+ }
+ }
+
public List<PropertyExtensionDescriptor> getPropertyExtensionDescriptors()
{
if (propertyExtensionDescriptors==null) {
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencePage.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencePage.java
index b679e5f2..43c7058a 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencePage.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencePage.java
@@ -720,7 +720,7 @@ public class ToolProfilesPreferencePage extends PreferencePage implements IWorkb
private Object[] loadModelEnablements(ToolProfilesPreferencesHelper helper, List<ModelEnablementTreeEntry> entries, List<ModelEnablementTreeEntry> bpmnEntries, ModelEnablementDescriptor med) {
entries.clear();
if (med!=null)
- entries.addAll(helper.getAllExtensionElements(med, bpmnEntries));
+ entries.addAll(helper.getAllExtensionElements(currentRuntime, med, bpmnEntries));
else
entries.addAll(helper.getAllElements());
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencesHelper.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencesHelper.java
index 4182767a..206af25b 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencesHelper.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/preferences/ToolProfilesPreferencesHelper.java
@@ -22,6 +22,7 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
+import java.util.Map.Entry;
import org.eclipse.bpmn2.Bpmn2Package;
import org.eclipse.bpmn2.modeler.core.preferences.ModelEnablements;
@@ -34,6 +35,7 @@ import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.osgi.service.prefs.BackingStoreException;
@@ -216,118 +218,64 @@ public class ToolProfilesPreferencesHelper {
return null;
}
- public List<ModelEnablementTreeEntry> getAllExtensionElements(ModelEnablementDescriptor me, List<ModelEnablementTreeEntry> bpmnEntries) {
+ public List<ModelEnablementTreeEntry> getAllExtensionElements(TargetRuntime rt, ModelEnablementDescriptor me, List<ModelEnablementTreeEntry> bpmnEntries) {
- // Fetch all of the <modelExtension> extension point elements defined
- // in the Target Runtime plugin.
+ // Fetch all of the <modelExtension> extension point elements defined in the Target Runtime plugin.
ArrayList<ModelEnablementTreeEntry> bpmnModelExtensions = new ArrayList<ModelEnablementTreeEntry>();
-
ModelEnablementTreeEntry bpmnModelExtensionsRoot = new ModelEnablementTreeEntry();
bpmnModelExtensionsRoot.setEnabled(true);
bpmnModelExtensionsRoot.setName(Messages.ToolEnablementPreferences_BPMN_Extensions);
-
- TargetRuntime rt = me.getRuntime();
- for (ModelExtensionDescriptor med : rt.getAllModelExtensionDescriptors()) {
- if (med.getProperties().size()>0) {
- // this <modelExtension> has at least one <property>
- // that can be enabled or disabled:
- // get the EClass which this <modelExtension> extends
- String className = med.getType();
- EClassifier eclass = me.getClassifier(className);
- if (eclass instanceof EClass) {
- // and create a ModelEnablementTreeEntry for it
- ModelEnablementTreeEntry entry = new ModelEnablementTreeEntry(eclass, bpmnModelExtensionsRoot);
- // fetch its current enablement state
- entry.setEnabled(isEnabled((EClass)eclass));
- // and add it to our list
- bpmnModelExtensions.add(entry);
- }
- }
-
- // now fetch all of the <property> elements contained
- // in the <modelExtension> element. The result list
- // so far contains only EClass entries; the <property>
- // elements will become their children.
- for (ModelEnablementTreeEntry entry : bpmnModelExtensions) {
- for (ModelExtensionDescriptor med2 : rt.getAllModelExtensionDescriptors()) {
- if (entry.getName().equals(med2.getType())) {
- ArrayList<ModelEnablementTreeEntry> children = new ArrayList<ModelEnablementTreeEntry>();
- for (Property p : med2.getProperties()) {
- EClass eclass = (EClass)entry.getElement();
- EStructuralFeature feature = me.getFeature(med2.getType(), p.name);
- if (feature==null)
- feature = med2.getFeature(eclass, p);
- if (feature instanceof EAttribute) {
- ModelEnablementTreeEntry child = findOrCreateEntry(bpmnEntries, feature, entry);
- // set enablement state of the feature:
- // the EClass is that of the parent entry.
- child.setEnabled(isEnabled(eclass, feature));
- children.add(child);
- }
- }
- // add the sorted list to the children of this entry parent
- sortElements(children);
- entry.setChildren(children);
- }
- }
+ for (Entry<EClass, List<EStructuralFeature>> e : rt.getModelExtensions(1).entrySet()) {
+ // create a ModelEnablementTreeEntry for extension EClass
+ EClass eClass = e.getKey();
+ ModelEnablementTreeEntry entry = new ModelEnablementTreeEntry(eClass, bpmnModelExtensionsRoot);
+ // fetch its current enablement state
+ entry.setEnabled(isEnabled(eClass));
+ // and add it to our list
+ bpmnModelExtensions.add(entry);
+ ArrayList<ModelEnablementTreeEntry> children = new ArrayList<ModelEnablementTreeEntry>();
+ for (EStructuralFeature feature : e.getValue()) {
+ ModelEnablementTreeEntry child = findOrCreateEntry(bpmnEntries, feature, entry);
+ // set enablement state of the feature:
+ // the EClass is that of the parent entry.
+ child.setEnabled(isEnabled(eClass, feature));
+ children.add(child);
}
- }
+ // add the sorted list to the children of this entry parent
+ sortElements(children);
+ entry.setChildren(children);
+ }
sortElements(bpmnModelExtensions);
bpmnModelExtensionsRoot.setChildren(bpmnModelExtensions);
+ ArrayList<ModelEnablementTreeEntry> runtimeModelExtensions = new ArrayList<ModelEnablementTreeEntry>();
ModelEnablementTreeEntry runtimeModelExtensionsRoot = new ModelEnablementTreeEntry();
runtimeModelExtensionsRoot.setEnabled(true);
runtimeModelExtensionsRoot.setName(Messages.ToolEnablementPreferences_Target_Extensions);
-
-
- ArrayList<ModelEnablementTreeEntry> runtimeModelExtensions = new ArrayList<ModelEnablementTreeEntry>();
-
- for (EClassifier ec : rt.getModelDescriptor().getEPackage().getEClassifiers()) {
- if (ec instanceof EClass) {
- EClass eclass = (EClass)ec;
- // skip over DocumentRoot - we'll assume that all of its features are
- // containers of, or references to EClasses which we'll process anyway.
- if (eclass.getName().equals("DocumentRoot")) //$NON-NLS-1$
- continue;
-
- ModelEnablementTreeEntry entry = new ModelEnablementTreeEntry(eclass, runtimeModelExtensionsRoot);
- // fetch its current enablement state
- entry.setEnabled(isEnabled((EClass)eclass));
- // and add it to our list
- runtimeModelExtensions.add(entry);
-
- HashSet<EStructuralFeature> possibleFeatures = new HashSet<EStructuralFeature>();
-
- ArrayList<ModelEnablementTreeEntry> children = new ArrayList<ModelEnablementTreeEntry>();
-
- for (EAttribute a : eclass.getEAllAttributes()) {
- possibleFeatures.add(a);
- }
-
- for (EReference a : eclass.getEAllContainments()) {
- possibleFeatures.add(a);
- }
-
- for (EReference a : eclass.getEAllReferences()) {
- possibleFeatures.add(a);
- }
-
- for (EStructuralFeature feature : possibleFeatures) {
- ModelEnablementTreeEntry modelEnablementTreeEntry = findOrCreateEntry(bpmnEntries, feature, entry);
- modelEnablementTreeEntry.setEnabled(isEnabled(eclass, feature));
- children.add(modelEnablementTreeEntry);
- }
- sortElements(children);
- entry.setChildren(children);
+ for (Entry<EClass, List<EStructuralFeature>> e : rt.getModelExtensions(2).entrySet()) {
+ // create a ModelEnablementTreeEntry for extension EClass
+ EClass eClass = e.getKey();
+ ModelEnablementTreeEntry entry = new ModelEnablementTreeEntry(eClass, runtimeModelExtensionsRoot);
+ // fetch its current enablement state
+ entry.setEnabled(isEnabled(eClass));
+ // and add it to our list
+ runtimeModelExtensions.add(entry);
+ ArrayList<ModelEnablementTreeEntry> children = new ArrayList<ModelEnablementTreeEntry>();
+ for (EStructuralFeature feature : e.getValue()) {
+ ModelEnablementTreeEntry child = findOrCreateEntry(bpmnEntries, feature, entry);
+ // set enablement state of the feature:
+ // the EClass is that of the parent entry.
+ child.setEnabled(isEnabled(eClass, feature));
+ children.add(child);
}
- }
+ // add the sorted list to the children of this entry parent
+ sortElements(children);
+ entry.setChildren(children);
+ }
sortElements(runtimeModelExtensions);
runtimeModelExtensionsRoot.setChildren(runtimeModelExtensions);
ArrayList<ModelEnablementTreeEntry> allExtensions = new ArrayList<ModelEnablementTreeEntry>();
-// allExtensions.addAll(bpmnModelExtensions);
-// allExtensions.addAll(runtimeModelExtensions);
-
allExtensions.add(bpmnModelExtensionsRoot);
allExtensions.add(runtimeModelExtensionsRoot);

Back to the top