Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Brodt2014-07-03 15:02:38 -0400
committerBob Brodt2014-07-03 15:02:38 -0400
commit804f2cc1a683c4a1668c8585b60499d289c70ec0 (patch)
tree4dc4d76acf86a1293e685a23f915ca0083e4ee3c
parentc33c69a4e67e6b8d7fed93e6779321ee3799604d (diff)
downloadorg.eclipse.bpmn2-modeler-804f2cc1a683c4a1668c8585b60499d289c70ec0.tar.gz
org.eclipse.bpmn2-modeler-804f2cc1a683c4a1668c8585b60499d289c70ec0.tar.xz
org.eclipse.bpmn2-modeler-804f2cc1a683c4a1668c8585b60499d289c70ec0.zip
Fix problems in example plugins
-rw-r--r--examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/plugin.xml68
-rw-r--r--examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyEventDefinitionFeatureContainer.java16
-rw-r--r--examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyTaskPropertySection.java40
-rw-r--r--examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/src/org/eclipse/bpmn2/modeler/examples/dynamic/SampleCustomTaskFeatureContainer.java21
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/adapters/ExtendedPropertiesAdapter.java7
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AbstractUpdateEventFeature.java2
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java6
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/diagram/BPMN2FeatureProvider.java16
8 files changed, 119 insertions, 57 deletions
diff --git a/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/plugin.xml b/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/plugin.xml
index 66c10aea..f40610e0 100644
--- a/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/plugin.xml
+++ b/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/plugin.xml
@@ -33,30 +33,7 @@
runtimeId="org.eclipse.bpmn2.modeler.examples.customtask.runtime"
type="Task">
<property name="type" value="MyTask" />
- <property name="taskConfig" label="Task Configuration">
- <value>
- <property name="parameters">
- <value>
- <property
- name="name"
- value="taskName" />
- <property
- name="value"
- value="My Custom Task" />
- </value>
- </property>
- <property name="parameters">
- <value>
- <property
- name="name"
- value="processingTime" />
- <property
- name="value"
- value="1 hr" />
- </value>
- </property>
- </value>
- </property>
+ <property name="taskConfig" label="Task Configuration" type="TaskConfig"/>
</customTask>
<customTask
@@ -82,8 +59,8 @@
name="My Event Definition"
propertyTabs="org.eclipse.bpmn2.modeler.examples.customtask.myEventDefinition.tab"
runtimeId="org.eclipse.bpmn2.modeler.examples.customtask.runtime"
- type="EventDefinition">
- <property name="type" value="MyEventDefinition" />
+ type="MyEventDefinition">
+ <property name="type" value="MyEventDefinition"/>
</customTask>
<customTask
@@ -94,9 +71,19 @@
id="org.eclipse.bpmn2.modeler.examples.customtask.temporalDependency"
name="Temporal Dependency"
runtimeId="org.eclipse.bpmn2.modeler.examples.timebpmn.runtime"
- type="FlowElement">
- <property name="lagTime" type="EString" value="3hr">
- </property>
+ type="TemporalDependency">
+ <property name="lagTime" type="EString" value="3hr"/>
+ </customTask>
+
+ <!-- This CustomTask defines a Start Event containing a MessageEventDefinition -->
+ <customTask
+ category="My Tools"
+ description="Message Start Event"
+ featureContainer="org.eclipse.bpmn2.modeler.examples.customtask.MessageStartEventFeatureContainer"
+ id="org.eclipse.bpmn2.modeler.examples.customtask.messageStartEvent"
+ name="Message Event"
+ runtimeId="org.eclipse.bpmn2.modeler.examples.timebpmn.runtime"
+ type="StartEvent">
</customTask>
<propertyTab
@@ -138,17 +125,18 @@
type="org.eclipse.bpmn2.modeler.examples.customtask.MyModel.MyEventDefinition"
class="org.eclipse.bpmn2.modeler.examples.customtask.MyEventDefinitionPropertiesAdapter">
</propertyExtension>
-
-
- <customTask
- category="My Tools"
- description="Message Start Event"
- featureContainer="org.eclipse.bpmn2.modeler.examples.customtask.MessageStartEventFeatureContainer"
- id="org.eclipse.bpmn2.modeler.examples.customtask.messageStartEvent"
- name="Message Event"
- runtimeId="org.eclipse.bpmn2.modeler.examples.timebpmn.runtime"
- type="StartEvent">
- </customTask>
+
+ <modelEnablement
+ runtimeId="org.eclipse.bpmn2.modeler.examples.customtask.runtime"
+ id="customtask.profile.1"
+ profile="Full"
+ description="All BPMN2 elements and attributes"
+ ref="org.eclipse.bpmn2.modeler.runtime.none:profile.1">
+ <enable object="TaskConfig"/>
+ <enable object="TemporalDependency"/>
+ <enable object="Parameter"/>
+ <enable object="MyEventDefinition"/>
+ </modelEnablement>
</extension>
diff --git a/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyEventDefinitionFeatureContainer.java b/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyEventDefinitionFeatureContainer.java
index 0320e1bc..c140327d 100644
--- a/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyEventDefinitionFeatureContainer.java
+++ b/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyEventDefinitionFeatureContainer.java
@@ -16,6 +16,7 @@ import org.eclipse.bpmn2.modeler.core.features.event.definitions.AbstractCreateE
import org.eclipse.bpmn2.modeler.core.features.event.definitions.AbstractEventDefinitionFeatureContainer;
import org.eclipse.bpmn2.modeler.core.features.event.definitions.DecorationAlgorithm;
import org.eclipse.bpmn2.modeler.core.runtime.CustomTaskImageProvider;
+import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
import org.eclipse.bpmn2.modeler.examples.customtask.MyModel.MyEventDefinition;
import org.eclipse.bpmn2.modeler.examples.customtask.MyModel.MyModelPackage;
import org.eclipse.emf.ecore.EClass;
@@ -24,9 +25,12 @@ import org.eclipse.graphiti.features.IAddFeature;
import org.eclipse.graphiti.features.ICreateFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.features.context.IContext;
import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.features.context.IPictogramElementContext;
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.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
@@ -47,7 +51,17 @@ public class MyEventDefinitionFeatureContainer extends CustomShapeFeatureContain
return null;
}
-
+
+ @Override
+ public Object getApplyObject(IContext context) {
+ if (context instanceof IPictogramElementContext) {
+ PictogramElement pe = ((IPictogramElementContext)context).getPictogramElement();
+ EObject bo = BusinessObjectUtil.getBusinessObjectForPictogramElement(pe);
+ return bo instanceof MyEventDefinition ? bo : null;
+ }
+ return null;
+ }
+
protected IShapeFeatureContainer createFeatureContainer(IFeatureProvider fp) {
return new AbstractEventDefinitionFeatureContainer() {
diff --git a/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyTaskPropertySection.java b/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyTaskPropertySection.java
index 395ad299..a96eeb8b 100644
--- a/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyTaskPropertySection.java
+++ b/examples/plugins/org.eclipse.bpmn2.modeler.examples.customtask/src/org/eclipse/bpmn2/modeler/examples/customtask/MyTaskPropertySection.java
@@ -10,11 +10,21 @@
******************************************************************************/
package org.eclipse.bpmn2.modeler.examples.customtask;
+import java.util.List;
+
+import org.eclipse.bpmn2.Task;
import org.eclipse.bpmn2.modeler.core.merrimac.clad.AbstractBpmn2PropertySection;
import org.eclipse.bpmn2.modeler.core.merrimac.clad.AbstractDetailComposite;
import org.eclipse.bpmn2.modeler.core.merrimac.clad.DefaultDetailComposite;
import org.eclipse.bpmn2.modeler.core.merrimac.clad.DefaultPropertySection;
+import org.eclipse.bpmn2.modeler.core.model.ModelDecorator;
+import org.eclipse.bpmn2.modeler.core.runtime.CustomTaskDescriptor;
+import org.eclipse.bpmn2.modeler.core.runtime.TargetRuntime;
+import org.eclipse.bpmn2.modeler.examples.customtask.MyModel.MyModelFactory;
+import org.eclipse.bpmn2.modeler.examples.customtask.MyModel.MyModelPackage;
+import org.eclipse.bpmn2.modeler.examples.customtask.MyModel.TaskConfig;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.swt.widgets.Composite;
public class MyTaskPropertySection extends DefaultPropertySection {
@@ -47,7 +57,35 @@ public class MyTaskPropertySection extends DefaultPropertySection {
@Override
public void createBindings(EObject be) {
- bindProperty(be, "extensionValues#TaskConfig.parameters");
+ // This must be a Task because this Property Tab is only active for Tasks.
+ // The Property Tab will only display the Parameter list in our TaskConfig
+ // model element (see the definition of this element in MyModel.ecore).
+ Task myTask = (Task)be;
+ TaskConfig taskConfig = null;
+ // Fetch all TaskConfig extension objects from the Task
+ List<TaskConfig> allTaskConfigs = ModelDecorator.getAllExtensionAttributeValues(myTask, TaskConfig.class);
+ if (allTaskConfigs.size()==0) {
+ // There are none, so we need to construct a new TaskConfig
+ // which is required by the Property Sheet UI.
+ taskConfig = MyModelFactory.eINSTANCE.createTaskConfig();
+ TargetRuntime rt = getTargetRuntime();
+ // We need our CustomTaskDescriptor for this Task. The ID must match
+ // the one defined in the <customTask> extension point in plugin.xml
+ CustomTaskDescriptor ctd = rt.getCustomTask("org.eclipse.bpmn2.modeler.examples.customtask.customTask1");
+ // Get the model feature for the "taskConfig" element name.
+ // Again, this must match the <property> element in <customTask>
+ EStructuralFeature feature = ctd.getModelDecorator().getEStructuralFeature(be, "taskConfig");
+ // Add the newly constructed TaskConfig object to the Task's Extension Values list.
+ // Note that we will delay the actual insertion of the new object until some feature
+ // of the object changes (e.g. the Parameter.name)
+ ModelDecorator.addExtensionAttributeValue(myTask, feature, taskConfig, true);
+ }
+ else {
+ // Else reuse the existing TaskConfig object.
+ taskConfig = allTaskConfigs.get(0);
+ }
+ // Display the Parameters list in TaskConfig
+ bindList(taskConfig, MyModelPackage.eINSTANCE.getTaskConfig_Parameters());
}
}
}
diff --git a/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/src/org/eclipse/bpmn2/modeler/examples/dynamic/SampleCustomTaskFeatureContainer.java b/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/src/org/eclipse/bpmn2/modeler/examples/dynamic/SampleCustomTaskFeatureContainer.java
index c6228a4a..abd2429c 100644
--- a/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/src/org/eclipse/bpmn2/modeler/examples/dynamic/SampleCustomTaskFeatureContainer.java
+++ b/examples/plugins/org.eclipse.bpmn2.modeler.examples.dynamic/src/org/eclipse/bpmn2/modeler/examples/dynamic/SampleCustomTaskFeatureContainer.java
@@ -13,18 +13,18 @@
package org.eclipse.bpmn2.modeler.examples.dynamic;
-import java.util.List;
-
import org.eclipse.bpmn2.TextAnnotation;
import org.eclipse.bpmn2.modeler.core.adapters.ExtendedPropertiesAdapter;
import org.eclipse.bpmn2.modeler.core.features.CustomShapeFeatureContainer;
import org.eclipse.bpmn2.modeler.core.features.IShapeFeatureContainer;
+import org.eclipse.bpmn2.modeler.core.features.MultiUpdateFeature;
import org.eclipse.bpmn2.modeler.core.features.artifact.AddTextAnnotationFeature;
import org.eclipse.bpmn2.modeler.core.features.artifact.UpdateTextAnnotationFeature;
+import org.eclipse.bpmn2.modeler.core.features.label.UpdateLabelFeature;
import org.eclipse.bpmn2.modeler.core.model.ModelDecorator;
import org.eclipse.bpmn2.modeler.core.preferences.ShapeStyle;
+import org.eclipse.bpmn2.modeler.core.preferences.ShapeStyle.LabelPosition;
import org.eclipse.bpmn2.modeler.core.utils.BusinessObjectUtil;
-import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.bpmn2.modeler.core.utils.StyleUtil;
import org.eclipse.bpmn2.modeler.examples.dynamic.SampleImageProvider.IconSize;
import org.eclipse.bpmn2.modeler.ui.features.artifact.CreateTextAnnotationFeature;
@@ -42,6 +42,7 @@ import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.graphiti.features.context.ICreateContext;
import org.eclipse.graphiti.features.context.IUpdateContext;
import org.eclipse.graphiti.features.impl.Reason;
+import org.eclipse.graphiti.mm.algorithms.AbstractText;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.Image;
import org.eclipse.graphiti.mm.algorithms.MultiText;
@@ -174,8 +175,8 @@ public class SampleCustomTaskFeatureContainer extends CustomShapeFeatureContaine
@Override
public IUpdateFeature getUpdateFeature(IFeatureProvider fp) {
- return new UpdateTextAnnotationFeature(fp) {
-
+ MultiUpdateFeature multiUpdate = new MultiUpdateFeature(fp);
+ multiUpdate.addFeature(new UpdateTextAnnotationFeature(fp) {
/* (non-Javadoc)
* @see org.eclipse.bpmn2.modeler.core.features.AbstractUpdateBaseElementFeature#updateNeeded(org.eclipse.graphiti.features.context.IUpdateContext)
*
@@ -214,8 +215,16 @@ public class SampleCustomTaskFeatureContainer extends CustomShapeFeatureContaine
setFillColor((ContainerShape)context.getPictogramElement());
return true;
}
+ });
+ multiUpdate.addFeature(new UpdateLabelFeature(fp) {
+
+ @Override
+ protected LabelPosition getLabelPosition(AbstractText text) {
+ return LabelPosition.CENTER;
+ }
- };
+ });
+ return multiUpdate;
}
@Override
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/adapters/ExtendedPropertiesAdapter.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/adapters/ExtendedPropertiesAdapter.java
index 0fa84551..91fea18e 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/adapters/ExtendedPropertiesAdapter.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/adapters/ExtendedPropertiesAdapter.java
@@ -24,6 +24,7 @@ import org.eclipse.bpmn2.modeler.core.utils.ModelUtil;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
@@ -159,8 +160,12 @@ public class ExtendedPropertiesAdapter<T extends EObject> extends ObjectProperty
adapter = genericAdapter;
EObject eclass = getFeatureClass(eObject,feature);
- if (adapter==null)
+ if (adapter==null) {
adapter = (ExtendedPropertiesAdapter) AdapterUtil.adapt(eclass, ExtendedPropertiesAdapter.class);
+ if (adapter==null) {
+ adapter = new ExtendedPropertiesAdapter(new AdapterFactoryImpl(), eObject);
+ }
+ }
if (adapter!=null) {
if (eObject instanceof EClass) {
EObject dummy = getDummyObject((EClass)eObject);
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AbstractUpdateEventFeature.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AbstractUpdateEventFeature.java
index b11772e3..d811819d 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AbstractUpdateEventFeature.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/features/event/AbstractUpdateEventFeature.java
@@ -87,7 +87,7 @@ public abstract class AbstractUpdateEventFeature<T extends Event> extends Abstra
}
// ...so we can create an UpdateContext...
UpdateContext context = new UpdateContext(eventDefinitionShape);
- // ...to look up the EventDefinitionUpdateFeature
+ // ...to look up the UpdateEventDefinitionFeature
IUpdateFeature upateFeature = getFeatureProvider().getUpdateFeature(context);
if (upateFeature!=null) {
// and do the update with the Event object (not the EventDefinition!)
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
index 2d403821..f4001e90 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/model/Bpmn2ModelerResourceImpl.java
@@ -956,7 +956,7 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
if (f == Bpmn2Package.eINSTANCE.getBaseElement_ExtensionValues()) {
// check if this element is (or should be) empty
- boolean shouldSave = false;
+ boolean shouldSave = true;
for (ExtensionAttributeValue ev : (EList<ExtensionAttributeValue>)o.eGet(f)) {
BasicFeatureMap map = (BasicFeatureMap) ev.getValue();
Iterator<FeatureMap.Entry> mi = map.iterator();
@@ -968,8 +968,8 @@ public class Bpmn2ModelerResourceImpl extends Bpmn2ResourceImpl {
while (ai.hasNext()) {
Adapter a = ai.next();
if (a instanceof IExtensionValueAdapter) {
- if (((IExtensionValueAdapter)a).shouldSaveElement((EObject)v)) {
- shouldSave = true;
+ if (!((IExtensionValueAdapter)a).shouldSaveElement((EObject)v)) {
+ shouldSave = false;
break;
}
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/diagram/BPMN2FeatureProvider.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/diagram/BPMN2FeatureProvider.java
index c8b9f773..fd1b0798 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/diagram/BPMN2FeatureProvider.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/diagram/BPMN2FeatureProvider.java
@@ -446,10 +446,18 @@ public class BPMN2FeatureProvider extends DefaultFeatureProvider implements IBpm
}
}
// last chance: check custom task feature containers
- if (id!=null && customTaskContainers!=null) {
- IFeatureContainer container = customTaskContainers.get(id);
- if (container!=null && container.getApplyObject(context)!=null)
- return container;
+ if (customTaskContainers!=null) {
+ if (id!=null) {
+ IFeatureContainer container = customTaskContainers.get(id);
+ if (container!=null && container.getApplyObject(context)!=null)
+ return container;
+ }
+ else {
+ for (IFeatureContainer container : customTaskContainers.values()) {
+ if (container.getApplyObject(context)!=null)
+ return container;
+ }
+ }
}
return null;
}

Back to the top