Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgolubev2012-04-29 15:46:13 +0000
committermgolubev2012-04-29 15:46:13 +0000
commitfeb5ad0c4a7512c4ebc155de70ef4b28417a8ad1 (patch)
tree9fb318423a3efb25488aef00743441a46e65c230
parent88b833fab2211ee0b6a1cbedc0cfc4f46b93a38c (diff)
parent4bce58657b67117b9658df74fd73e76a14afa8f9 (diff)
downloadorg.eclipse.gmf-tooling-feb5ad0c4a7512c4ebc155de70ef4b28417a8ad1.tar.gz
org.eclipse.gmf-tooling-feb5ad0c4a7512c4ebc155de70ef4b28417a8ad1.tar.xz
org.eclipse.gmf-tooling-feb5ad0c4a7512c4ebc155de70ef4b28417a8ad1.zip
Merge branch '158116-(workaround)-copy-directedit-to-gmfruntime' into 3.0.M7-merging-all
-rw-r--r--plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java168
-rw-r--r--plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/OclChoiceParser.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/PredefinedEnumParser.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.gmf.codegen.edit/plugin.properties5
-rw-r--r--plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GMFGenItemProviderAdapterFactory.java48
-rw-r--r--plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GenParsersItemProvider.java10
-rw-r--r--plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/OclChoiceParserItemProvider.java178
-rw-r--r--plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/PredefinedEnumParserItemProvider.java119
-rw-r--r--plugins/org.eclipse.gmf.codegen/models/gmfgen.ecore8
-rw-r--r--plugins/org.eclipse.gmf.codegen/models/gmfgen.emf11
-rw-r--r--plugins/org.eclipse.gmf.codegen/models/gmfgen.genmodel8
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenFactory.java18
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenPackage.java172
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/OclChoiceParser.java87
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/PredefinedEnumParser.java29
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenFactoryImpl.java22
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java62
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/OclChoiceParserImpl.java233
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/PredefinedEnumParserImpl.java54
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenAdapterFactory.java36
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenSwitch.java44
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java2
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/ChoiceUtils.qvto44
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/TextAware.xpt99
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt94
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/EditPartFactory.xpt26
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/AbstractExpression.xpt0
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/OCLExpressionFactory.xpt34
-rw-r--r--[-rwxr-xr-x]plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/RegexpExpressionFactory.xpt0
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt14
-rw-r--r--plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateMappingEntry_labelMappings_OclChoiceLabelMapping.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_Constraint.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_ValueExpression.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_Constraint.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_ValueExpression.gifbin0 -> 223 bytes
-rw-r--r--plugins/org.eclipse.gmf.map.edit/icons/full/obj16/OclChoiceLabelMapping.gifbin0 -> 129 bytes
-rw-r--r--plugins/org.eclipse.gmf.map.edit/plugin.properties11
-rw-r--r--plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/GMFMapItemProviderAdapterFactory.java24
-rw-r--r--plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/MappingEntryItemProvider.java5
-rw-r--r--plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/NodeReferenceItemProvider.java3
-rw-r--r--plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/OclChoiceLabelMappingItemProvider.java273
-rw-r--r--plugins/org.eclipse.gmf.map/models/gmfmap.ecore24
-rw-r--r--plugins/org.eclipse.gmf.map/models/gmfmap.emf10
-rw-r--r--plugins/org.eclipse.gmf.map/models/gmfmap.genmodel7
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapFactory.java9
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapPackage.java172
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/OclChoiceLabelMapping.java115
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapFactoryImpl.java11
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java83
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/OclChoiceLabelMappingImpl.java306
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapAdapterFactory.java18
-rw-r--r--plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapSwitch.java22
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/messages.properties6
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/GMFToolingRuntimePlugin.java24
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/Messages.java6
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorEx.java26
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorExDelegate.java77
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboCellEditorEx.java129
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboDirectEditManager.java86
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/DirectEditManagerBase.java565
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextCellEditorEx.java138
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextDirectEditManager2.java208
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/WrapTextCellEditor.java80
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclDependencyCollector.java9
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclEvaluator.java11
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclListener.java6
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclResult.java18
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclDependencyCollectorBase.java39
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclEvaluatorImpl.java20
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclResultImpl.java78
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTracker.java100
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTrackerFactory.java17
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextData.java31
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextDataWithAdapter.java35
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/DependencyEvaluator.java29
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EcoreEnvironmentFactoryEx.java50
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EvaluationVisitorImplEx.java50
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ListeningDependencyCollector.java25
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/SimpleDependencyCollector.java11
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/HasOclTracker.java6
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTracker.java29
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerBase.java34
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerFactory.java14
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractAttributeParser.java227
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractFeatureParser.java145
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractParser.java418
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ChoiceParserBase.java74
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/EnumParser.java38
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ExpressionLabelParserBase.java46
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclChoiceParser.java174
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerChoiceParser.java61
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerWrapper.java41
93 files changed, 5379 insertions, 530 deletions
diff --git a/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java b/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java
index 311356ae7..aa01d4289 100644
--- a/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java
+++ b/plugins/org.eclipse.gmf.bridge/src/org/eclipse/gmf/internal/bridge/genmodel/DiagramGenModelTransformer.java
@@ -25,15 +25,93 @@ import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.gmf.codegen.gmfgen.*;
+import org.eclipse.gmf.codegen.gmfgen.DesignLabelModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.ElementType;
+import org.eclipse.gmf.codegen.gmfgen.ExpressionLabelModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.ExpressionLabelParser;
+import org.eclipse.gmf.codegen.gmfgen.ExternalParser;
+import org.eclipse.gmf.codegen.gmfgen.FeatureLabelModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.FeatureLinkModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
+import org.eclipse.gmf.codegen.gmfgen.GenActionFactoryContributionItem;
+import org.eclipse.gmf.codegen.gmfgen.GenApplication;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditContext;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRoot;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditRule;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditable;
+import org.eclipse.gmf.codegen.gmfgen.GenAuditedMetricTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenChildContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenChildLabelNode;
+import org.eclipse.gmf.codegen.gmfgen.GenChildNode;
+import org.eclipse.gmf.codegen.gmfgen.GenChildSideAffixedNode;
+import org.eclipse.gmf.codegen.gmfgen.GenCommonBase;
+import org.eclipse.gmf.codegen.gmfgen.GenCompartment;
+import org.eclipse.gmf.codegen.gmfgen.GenConstraint;
+import org.eclipse.gmf.codegen.gmfgen.GenContextMenu;
+import org.eclipse.gmf.codegen.gmfgen.GenContributionItem;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagramElementTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenDomainAttributeTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenDomainElementTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenElementInitializer;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionInterpreter;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderBase;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenFeatureInitializer;
+import org.eclipse.gmf.codegen.gmfgen.GenFeatureSeqInitializer;
+import org.eclipse.gmf.codegen.gmfgen.GenFeatureValueSpec;
+import org.eclipse.gmf.codegen.gmfgen.GenGroupMarker;
+import org.eclipse.gmf.codegen.gmfgen.GenLanguage;
+import org.eclipse.gmf.codegen.gmfgen.GenLink;
+import org.eclipse.gmf.codegen.gmfgen.GenLinkConstraints;
+import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenMeasurable;
+import org.eclipse.gmf.codegen.gmfgen.GenMenuManager;
+import org.eclipse.gmf.codegen.gmfgen.GenMetricContainer;
+import org.eclipse.gmf.codegen.gmfgen.GenMetricRule;
+import org.eclipse.gmf.codegen.gmfgen.GenNavigator;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenNotationElementTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenParserImplementation;
+import org.eclipse.gmf.codegen.gmfgen.GenParsers;
+import org.eclipse.gmf.codegen.gmfgen.GenPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenPropertySheet;
+import org.eclipse.gmf.codegen.gmfgen.GenReferenceNewElementSpec;
+import org.eclipse.gmf.codegen.gmfgen.GenRuleTarget;
+import org.eclipse.gmf.codegen.gmfgen.GenSeparator;
+import org.eclipse.gmf.codegen.gmfgen.GenSeverity;
+import org.eclipse.gmf.codegen.gmfgen.GenSharedContributionItem;
+import org.eclipse.gmf.codegen.gmfgen.GenStandardPreferencePage;
+import org.eclipse.gmf.codegen.gmfgen.GenToolBarManager;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.LabelModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.LabelOffsetAttributes;
import org.eclipse.gmf.codegen.gmfgen.LabelTextAccessMethod;
+import org.eclipse.gmf.codegen.gmfgen.LinkLabelAlignment;
+import org.eclipse.gmf.codegen.gmfgen.LinkModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.MetamodelType;
+import org.eclipse.gmf.codegen.gmfgen.OclChoiceParser;
+import org.eclipse.gmf.codegen.gmfgen.OpenDiagramBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.Palette;
+import org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser;
+import org.eclipse.gmf.codegen.gmfgen.PredefinedParser;
+import org.eclipse.gmf.codegen.gmfgen.ProviderPriority;
+import org.eclipse.gmf.codegen.gmfgen.SpecializationType;
+import org.eclipse.gmf.codegen.gmfgen.StandardPreferencePages;
+import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet;
import org.eclipse.gmf.codegen.gmfgen.ValueExpression;
import org.eclipse.gmf.gmfgraph.Alignment;
import org.eclipse.gmf.gmfgraph.AlignmentFacet;
@@ -50,8 +128,39 @@ import org.eclipse.gmf.internal.bridge.VisualIdentifierDispenser;
import org.eclipse.gmf.internal.bridge.genmodel.navigator.NavigatorHandler;
import org.eclipse.gmf.internal.bridge.tooldef.PaletteHandler;
import org.eclipse.gmf.internal.codegen.util.Extras;
-import org.eclipse.gmf.mappings.*;
+import org.eclipse.gmf.mappings.AuditContainer;
+import org.eclipse.gmf.mappings.AuditRule;
+import org.eclipse.gmf.mappings.AuditedMetricTarget;
+import org.eclipse.gmf.mappings.CanvasMapping;
+import org.eclipse.gmf.mappings.ChildReference;
+import org.eclipse.gmf.mappings.CompartmentMapping;
+import org.eclipse.gmf.mappings.Constraint;
+import org.eclipse.gmf.mappings.DesignLabelMapping;
+import org.eclipse.gmf.mappings.DiagramElementTarget;
+import org.eclipse.gmf.mappings.DomainAttributeTarget;
+import org.eclipse.gmf.mappings.DomainElementTarget;
+import org.eclipse.gmf.mappings.ElementInitializer;
+import org.eclipse.gmf.mappings.ExpressionLabelMapping;
+import org.eclipse.gmf.mappings.FeatureInitializer;
+import org.eclipse.gmf.mappings.FeatureLabelMapping;
+import org.eclipse.gmf.mappings.FeatureSeqInitializer;
+import org.eclipse.gmf.mappings.FeatureValueSpec;
+import org.eclipse.gmf.mappings.GMFMapPackage;
+import org.eclipse.gmf.mappings.LabelMapping;
+import org.eclipse.gmf.mappings.Language;
import org.eclipse.gmf.mappings.LinkConstraints;
+import org.eclipse.gmf.mappings.LinkMapping;
+import org.eclipse.gmf.mappings.Mapping;
+import org.eclipse.gmf.mappings.MappingEntry;
+import org.eclipse.gmf.mappings.MetricContainer;
+import org.eclipse.gmf.mappings.MetricRule;
+import org.eclipse.gmf.mappings.NodeMapping;
+import org.eclipse.gmf.mappings.NodeReference;
+import org.eclipse.gmf.mappings.NotationElementTarget;
+import org.eclipse.gmf.mappings.OclChoiceLabelMapping;
+import org.eclipse.gmf.mappings.ReferenceNewElementSpec;
+import org.eclipse.gmf.mappings.Severity;
+import org.eclipse.gmf.mappings.TopNodeReference;
/**
* Creates generation model from diagram definition.
@@ -593,6 +702,15 @@ public class DiagramGenModelTransformer extends MappingTransformer {
// XXX
return modelFacet;
}
+ if (mapping instanceof OclChoiceLabelMapping) {
+ OclChoiceLabelMapping oclMapping = (OclChoiceLabelMapping) mapping;
+ FeatureLabelModelFacet modelFacet = GMFGenFactory.eINSTANCE.createFeatureLabelModelFacet();
+ GenFeature feature = findGenFeature(oclMapping.getFeature());
+ modelFacet.getMetaFeatures().add(feature);
+ modelFacet.getEditableMetaFeatures().add(feature);
+ modelFacet.setParser(createOclChoiceParser(oclMapping));
+ return modelFacet;
+ }
if (mapping instanceof DesignLabelMapping) {
DesignLabelModelFacet modelFacet = GMFGenFactory.eINSTANCE.createDesignLabelModelFacet();
modelFacet.setParser(getOrCreateParser((DesignLabelMapping) mapping));
@@ -1310,6 +1428,52 @@ public class DiagramGenModelTransformer extends MappingTransformer {
}
private GenParserImplementation getOrCreateParser(FeatureLabelMapping flMapping) {
+ if (isEnumLabelMapping(flMapping)) {
+ return getOrCreateEnumParser(flMapping);
+ } else {
+ return getOrCreatePredefinedParser(flMapping);
+ }
+ }
+
+ private boolean isEnumLabelMapping(FeatureLabelMapping flMapping) {
+ EList<EAttribute> features = flMapping.getFeatures();
+ EList<EAttribute> editFeatures = flMapping.getEditableFeatures();
+ if (features.size() != 1){
+ return false;
+ }
+ if (editFeatures.size() > features.size()){
+ return false;
+ }
+ if (!editFeatures.isEmpty() && editFeatures.get(0) != features.get(0)) {
+ return false;
+ }
+ return features.get(0).getEType() instanceof EEnum;
+ }
+
+ private GenParserImplementation getOrCreateEnumParser(FeatureLabelMapping flMapping) {
+ for (GenParserImplementation pi : getGenParsers().getImplementations()) {
+ if (pi instanceof PredefinedEnumParser) {
+ return (PredefinedEnumParser) pi;
+ }
+ }
+ PredefinedEnumParser result = GMFGenFactory.eINSTANCE.createPredefinedEnumParser();
+ getGenParsers().getImplementations().add(result);
+ return result;
+ }
+
+ private GenParserImplementation createOclChoiceParser(OclChoiceLabelMapping oclMapping) {
+ OclChoiceParser result = GMFGenFactory.eINSTANCE.createOclChoiceParser();
+ if (oclMapping.getItemsExpression() != null) {
+ result.setItemsExpression(createValueExpression(oclMapping.getItemsExpression()));
+ }
+ if (oclMapping.getShowExpression() != null) {
+ result.setShowExpression(createValueExpression(oclMapping.getShowExpression()));
+ }
+ getGenParsers().getImplementations().add(result);
+ return result;
+ }
+
+ private GenParserImplementation getOrCreatePredefinedParser(FeatureLabelMapping flMapping) {
final LabelTextAccessMethod editMethod = LabelTextAccessMethod.get(flMapping.getEditMethod().getValue());
final LabelTextAccessMethod viewMethod = LabelTextAccessMethod.get(flMapping.getViewMethod().getValue());
for (GenParserImplementation pi : getGenParsers().getImplementations()) {
diff --git a/plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/OclChoiceParser.gif b/plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/OclChoiceParser.gif
new file mode 100644
index 000000000..a17dc7d88
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/OclChoiceParser.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/PredefinedEnumParser.gif b/plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/PredefinedEnumParser.gif
new file mode 100644
index 000000000..05dc74ad5
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.edit/icons/full/obj16/PredefinedEnumParser.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.codegen.edit/plugin.properties b/plugins/org.eclipse.gmf.codegen.edit/plugin.properties
index df59b94b2..5da5fcd4f 100644
--- a/plugins/org.eclipse.gmf.codegen.edit/plugin.properties
+++ b/plugins/org.eclipse.gmf.codegen.edit/plugin.properties
@@ -929,3 +929,8 @@ _UI_ExpressionLabelParser_expressionContext_feature = Expression Context
_UI_ExpressionLabelParser_viewExpression_feature = View Expression
_UI_ExpressionLabelParser_editExpression_feature = Edit Expression
_UI_ExpressionLabelParser_validateExpression_feature = Validate Expression
+_UI_PredefinedEnumParser_type = Predefined Enum Parser
+_UI_OclChoiceParser_type = Ocl Choice Parser
+_UI_OclChoiceParser_itemsExpression_feature = Items Expression
+_UI_OclChoiceParser_showExpression_feature = Show Expression
+_UI_OclChoiceParser_expressionContext_feature = Expression Context
diff --git a/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GMFGenItemProviderAdapterFactory.java b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GMFGenItemProviderAdapterFactory.java
index 11aab273d..91d9df3cf 100644
--- a/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GMFGenItemProviderAdapterFactory.java
+++ b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GMFGenItemProviderAdapterFactory.java
@@ -2251,6 +2251,52 @@ public class GMFGenItemProviderAdapterFactory extends GMFGenAdapterFactory imple
}
/**
+ * This keeps track of the one adapter used for all {@link org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected PredefinedEnumParserItemProvider predefinedEnumParserItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createPredefinedEnumParserAdapter() {
+ if (predefinedEnumParserItemProvider == null) {
+ predefinedEnumParserItemProvider = new PredefinedEnumParserItemProvider(this);
+ }
+
+ return predefinedEnumParserItemProvider;
+ }
+
+ /**
+ * This keeps track of the one adapter used for all {@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected OclChoiceParserItemProvider oclChoiceParserItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createOclChoiceParserAdapter() {
+ if (oclChoiceParserItemProvider == null) {
+ oclChoiceParserItemProvider = new OclChoiceParserItemProvider(this);
+ }
+
+ return oclChoiceParserItemProvider;
+ }
+
+ /**
* This keeps track of the one adapter used for all {@link org.eclipse.gmf.codegen.gmfgen.ExpressionLabelParser} instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2587,6 +2633,8 @@ public class GMFGenItemProviderAdapterFactory extends GMFGenAdapterFactory imple
if (genApplicationItemProvider != null) genApplicationItemProvider.dispose();
if (genParsersItemProvider != null) genParsersItemProvider.dispose();
if (predefinedParserItemProvider != null) predefinedParserItemProvider.dispose();
+ if (predefinedEnumParserItemProvider != null) predefinedEnumParserItemProvider.dispose();
+ if (oclChoiceParserItemProvider != null) oclChoiceParserItemProvider.dispose();
if (expressionLabelParserItemProvider != null) expressionLabelParserItemProvider.dispose();
if (customParserItemProvider != null) customParserItemProvider.dispose();
if (externalParserItemProvider != null) externalParserItemProvider.dispose();
diff --git a/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GenParsersItemProvider.java b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GenParsersItemProvider.java
index 645376b85..fba82f679 100644
--- a/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GenParsersItemProvider.java
+++ b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/GenParsersItemProvider.java
@@ -297,6 +297,16 @@ public class GenParsersItemProvider
newChildDescriptors.add
(createChildParameter
(GMFGenPackage.eINSTANCE.getGenParsers_Implementations(),
+ GMFGenFactory.eINSTANCE.createPredefinedEnumParser()));
+
+ newChildDescriptors.add
+ (createChildParameter
+ (GMFGenPackage.eINSTANCE.getGenParsers_Implementations(),
+ GMFGenFactory.eINSTANCE.createOclChoiceParser()));
+
+ newChildDescriptors.add
+ (createChildParameter
+ (GMFGenPackage.eINSTANCE.getGenParsers_Implementations(),
GMFGenFactory.eINSTANCE.createExpressionLabelParser()));
newChildDescriptors.add
diff --git a/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/OclChoiceParserItemProvider.java b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/OclChoiceParserItemProvider.java
new file mode 100644
index 000000000..980ee0303
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/OclChoiceParserItemProvider.java
@@ -0,0 +1,178 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.codegen.gmfgen.provider;
+
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+
+import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
+import org.eclipse.gmf.codegen.gmfgen.OclChoiceParser;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class OclChoiceParserItemProvider
+ extends GenParserImplementationItemProvider
+ implements
+ IEditingDomainItemProvider,
+ IStructuredItemContentProvider,
+ ITreeItemContentProvider,
+ IItemLabelProvider,
+ IItemPropertySource {
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public OclChoiceParserItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addItemsExpressionPropertyDescriptor(object);
+ addShowExpressionPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Items Expression feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addItemsExpressionPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_OclChoiceParser_itemsExpression_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_OclChoiceParser_itemsExpression_feature", "_UI_OclChoiceParser_type"),
+ GMFGenPackage.eINSTANCE.getOclChoiceParser_ItemsExpression(),
+ true,
+ false,
+ false,
+ null,
+ null,
+ null));
+ }
+
+ /**
+ * This adds a property descriptor for the Show Expression feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void addShowExpressionPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_OclChoiceParser_showExpression_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_OclChoiceParser_showExpression_feature", "_UI_OclChoiceParser_type"),
+ GMFGenPackage.eINSTANCE.getOclChoiceParser_ShowExpression(),
+ true,
+ false,
+ false,
+ null,
+ null,
+ null));
+ }
+
+ /**
+ * This returns OclChoiceParser.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/OclChoiceParser"));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean shouldComposeCreationImage() {
+ return true;
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ return getString("_UI_OclChoiceParser_type");
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(OclChoiceParser.class)) {
+ case GMFGenPackage.OCL_CHOICE_PARSER__ITEMS_EXPRESSION:
+ case GMFGenPackage.OCL_CHOICE_PARSER__SHOW_EXPRESSION:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/PredefinedEnumParserItemProvider.java b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/PredefinedEnumParserItemProvider.java
new file mode 100644
index 000000000..4880b4dc8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.edit/src/org/eclipse/gmf/codegen/gmfgen/provider/PredefinedEnumParserItemProvider.java
@@ -0,0 +1,119 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.codegen.gmfgen.provider;
+
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+
+/**
+ * This is the item provider adapter for a {@link org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser} object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class PredefinedEnumParserItemProvider
+ extends GenParserImplementationItemProvider
+ implements
+ IEditingDomainItemProvider,
+ IStructuredItemContentProvider,
+ ITreeItemContentProvider,
+ IItemLabelProvider,
+ IItemPropertySource {
+ /**
+ * This constructs an instance from a factory and a notifier.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public PredefinedEnumParserItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This returns PredefinedEnumParser.gif.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/PredefinedEnumParser"));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean shouldComposeCreationImage() {
+ return true;
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ return getString("_UI_PredefinedEnumParser_type");
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children
+ * that can be created under this object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.codegen/models/gmfgen.ecore b/plugins/org.eclipse.gmf.codegen/models/gmfgen.ecore
index fa8296658..4c19d172c 100644
--- a/plugins/org.eclipse.gmf.codegen/models/gmfgen.ecore
+++ b/plugins/org.eclipse.gmf.codegen/models/gmfgen.ecore
@@ -2298,6 +2298,14 @@
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="PredefinedEnumParser" eSuperTypes="#//GenParserImplementation">
+ <eOperations name="getQualifiedClassName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="OclChoiceParser" eSuperTypes="#//GenParserImplementation">
+ <eOperations name="getQualifiedClassName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="itemsExpression" eType="#//ValueExpression"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="showExpression" eType="#//ValueExpression"/>
+ </eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ExpressionLabelParser" eSuperTypes="#//GenParserImplementation">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Parser implementation that uses expressions to produce string values"/>
diff --git a/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf b/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf
index 24733ceb9..a67df8610 100644
--- a/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf
+++ b/plugins/org.eclipse.gmf.codegen/models/gmfgen.emf
@@ -1596,6 +1596,17 @@ class PredefinedParser extends GenParserImplementation {
op String getQualifiedClassName();
}
+class PredefinedEnumParser extends GenParserImplementation {
+ op String getQualifiedClassName();
+}
+
+class OclChoiceParser extends GenParserImplementation {
+ op String getQualifiedClassName();
+
+ ref ValueExpression[?] itemsExpression;
+ ref ValueExpression[?] showExpression;
+}
+
@genmodel(documentation="Parser implementation that uses expressions to produce string values")
class ExpressionLabelParser extends GenParserImplementation {
@genmodel(documentation="Provides means to alter name of parser implementation class")
diff --git a/plugins/org.eclipse.gmf.codegen/models/gmfgen.genmodel b/plugins/org.eclipse.gmf.codegen/models/gmfgen.genmodel
index 720f4537d..78f436ee5 100644
--- a/plugins/org.eclipse.gmf.codegen/models/gmfgen.genmodel
+++ b/plugins/org.eclipse.gmf.codegen/models/gmfgen.genmodel
@@ -1033,6 +1033,14 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute gmfgen.ecore#//PredefinedParser/className"/>
<genOperations ecoreOperation="gmfgen.ecore#//PredefinedParser/getQualifiedClassName"/>
</genClasses>
+ <genClasses ecoreClass="gmfgen.ecore#//PredefinedEnumParser">
+ <genOperations ecoreOperation="gmfgen.ecore#//PredefinedEnumParser/getQualifiedClassName"/>
+ </genClasses>
+ <genClasses ecoreClass="gmfgen.ecore#//OclChoiceParser">
+ <genFeatures createChild="false" ecoreFeature="ecore:EReference gmfgen.ecore#//OclChoiceParser/itemsExpression"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EReference gmfgen.ecore#//OclChoiceParser/showExpression"/>
+ <genOperations ecoreOperation="gmfgen.ecore#//OclChoiceParser/getQualifiedClassName"/>
+ </genClasses>
<genClasses ecoreClass="gmfgen.ecore#//ExpressionLabelParser">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute gmfgen.ecore#//ExpressionLabelParser/className"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference gmfgen.ecore#//ExpressionLabelParser/expressionContext"/>
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenFactory.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenFactory.java
index 66bc942c1..0d847d8d4 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenFactory.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenFactory.java
@@ -872,6 +872,24 @@ public interface GMFGenFactory extends EFactory {
PredefinedParser createPredefinedParser();
/**
+ * Returns a new object of class '<em>Predefined Enum Parser</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Predefined Enum Parser</em>'.
+ * @generated
+ */
+ PredefinedEnumParser createPredefinedEnumParser();
+
+ /**
+ * Returns a new object of class '<em>Ocl Choice Parser</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Ocl Choice Parser</em>'.
+ * @generated
+ */
+ OclChoiceParser createOclChoiceParser();
+
+ /**
* Returns a new object of class '<em>Expression Label Parser</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenPackage.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenPackage.java
index e3ac1c620..a205c85db 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenPackage.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/GMFGenPackage.java
@@ -10756,6 +10756,98 @@ public interface GMFGenPackage extends EPackage {
int PREDEFINED_PARSER_FEATURE_COUNT = GEN_PARSER_IMPLEMENTATION_FEATURE_COUNT + 3;
/**
+ * The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.impl.PredefinedEnumParserImpl <em>Predefined Enum Parser</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.gmf.codegen.gmfgen.impl.PredefinedEnumParserImpl
+ * @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getPredefinedEnumParser()
+ * @generated
+ */
+ int PREDEFINED_ENUM_PARSER = 136;
+
+ /**
+ * The feature id for the '<em><b>Holder</b></em>' container reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int PREDEFINED_ENUM_PARSER__HOLDER = GEN_PARSER_IMPLEMENTATION__HOLDER;
+
+ /**
+ * The feature id for the '<em><b>Uses</b></em>' reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int PREDEFINED_ENUM_PARSER__USES = GEN_PARSER_IMPLEMENTATION__USES;
+
+ /**
+ * The number of structural features of the '<em>Predefined Enum Parser</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int PREDEFINED_ENUM_PARSER_FEATURE_COUNT = GEN_PARSER_IMPLEMENTATION_FEATURE_COUNT + 0;
+
+ /**
+ * The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.impl.OclChoiceParserImpl <em>Ocl Choice Parser</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.gmf.codegen.gmfgen.impl.OclChoiceParserImpl
+ * @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getOclChoiceParser()
+ * @generated
+ */
+ int OCL_CHOICE_PARSER = 137;
+
+ /**
+ * The feature id for the '<em><b>Holder</b></em>' container reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_PARSER__HOLDER = GEN_PARSER_IMPLEMENTATION__HOLDER;
+
+ /**
+ * The feature id for the '<em><b>Uses</b></em>' reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_PARSER__USES = GEN_PARSER_IMPLEMENTATION__USES;
+
+ /**
+ * The feature id for the '<em><b>Items Expression</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_PARSER__ITEMS_EXPRESSION = GEN_PARSER_IMPLEMENTATION_FEATURE_COUNT + 0;
+
+ /**
+ * The feature id for the '<em><b>Show Expression</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_PARSER__SHOW_EXPRESSION = GEN_PARSER_IMPLEMENTATION_FEATURE_COUNT + 1;
+
+ /**
+ * The number of structural features of the '<em>Ocl Choice Parser</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_PARSER_FEATURE_COUNT = GEN_PARSER_IMPLEMENTATION_FEATURE_COUNT + 2;
+
+ /**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.impl.ExpressionLabelParserImpl <em>Expression Label Parser</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -10763,7 +10855,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getExpressionLabelParser()
* @generated
*/
- int EXPRESSION_LABEL_PARSER = 136;
+ int EXPRESSION_LABEL_PARSER = 138;
/**
* The feature id for the '<em><b>Holder</b></em>' container reference.
@@ -10845,7 +10937,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getCustomParser()
* @generated
*/
- int CUSTOM_PARSER = 137;
+ int CUSTOM_PARSER = 139;
/**
* The feature id for the '<em><b>Holder</b></em>' container reference.
@@ -10900,7 +10992,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getExternalParser()
* @generated
*/
- int EXTERNAL_PARSER = 138;
+ int EXTERNAL_PARSER = 140;
/**
* The feature id for the '<em><b>Holder</b></em>' container reference.
@@ -10946,7 +11038,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getStandardPreferencePages()
* @generated
*/
- int STANDARD_PREFERENCE_PAGES = 139;
+ int STANDARD_PREFERENCE_PAGES = 141;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.RulerUnits <em>Ruler Units</em>}' enum.
@@ -10956,7 +11048,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getRulerUnits()
* @generated
*/
- int RULER_UNITS = 140;
+ int RULER_UNITS = 142;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.Routing <em>Routing</em>}' enum.
@@ -10966,7 +11058,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getRouting()
* @generated
*/
- int ROUTING = 141;
+ int ROUTING = 143;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.LineStyle <em>Line Style</em>}' enum.
@@ -10976,7 +11068,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getLineStyle()
* @generated
*/
- int LINE_STYLE = 142;
+ int LINE_STYLE = 144;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.JFaceFont <em>JFace Font</em>}' enum.
@@ -10986,7 +11078,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getJFaceFont()
* @generated
*/
- int JFACE_FONT = 143;
+ int JFACE_FONT = 145;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.FontStyle <em>Font Style</em>}' enum.
@@ -10996,7 +11088,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getFontStyle()
* @generated
*/
- int FONT_STYLE = 144;
+ int FONT_STYLE = 146;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.DiagramColors <em>Diagram Colors</em>}' enum.
@@ -11006,7 +11098,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getDiagramColors()
* @generated
*/
- int DIAGRAM_COLORS = 145;
+ int DIAGRAM_COLORS = 147;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.ProviderPriority <em>Provider Priority</em>}' enum.
@@ -11016,7 +11108,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getProviderPriority()
* @generated
*/
- int PROVIDER_PRIORITY = 146;
+ int PROVIDER_PRIORITY = 148;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.LinkLabelAlignment <em>Link Label Alignment</em>}' enum.
@@ -11026,7 +11118,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getLinkLabelAlignment()
* @generated
*/
- int LINK_LABEL_ALIGNMENT = 147;
+ int LINK_LABEL_ALIGNMENT = 149;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.LabelTextAccessMethod <em>Label Text Access Method</em>}' enum.
@@ -11036,7 +11128,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getLabelTextAccessMethod()
* @generated
*/
- int LABEL_TEXT_ACCESS_METHOD = 148;
+ int LABEL_TEXT_ACCESS_METHOD = 150;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.ViewmapLayoutType <em>Viewmap Layout Type</em>}' enum.
@@ -11046,7 +11138,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getViewmapLayoutType()
* @generated
*/
- int VIEWMAP_LAYOUT_TYPE = 149;
+ int VIEWMAP_LAYOUT_TYPE = 151;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.StandardEntryKind <em>Standard Entry Kind</em>}' enum.
@@ -11056,7 +11148,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getStandardEntryKind()
* @generated
*/
- int STANDARD_ENTRY_KIND = 150;
+ int STANDARD_ENTRY_KIND = 152;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.GenSeverity <em>Gen Severity</em>}' enum.
@@ -11066,7 +11158,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getGenSeverity()
* @generated
*/
- int GEN_SEVERITY = 151;
+ int GEN_SEVERITY = 153;
/**
* The meta object id for the '{@link org.eclipse.gmf.codegen.gmfgen.GenLanguage <em>Gen Language</em>}' enum.
@@ -11076,7 +11168,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getGenLanguage()
* @generated
*/
- int GEN_LANGUAGE = 152;
+ int GEN_LANGUAGE = 154;
/**
@@ -11087,7 +11179,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getGenNavigatorReferenceType()
* @generated
*/
- int GEN_NAVIGATOR_REFERENCE_TYPE = 153;
+ int GEN_NAVIGATOR_REFERENCE_TYPE = 155;
/**
@@ -11098,7 +11190,7 @@ public interface GMFGenPackage extends EPackage {
* @see org.eclipse.gmf.codegen.gmfgen.impl.GMFGenPackageImpl#getGeneratedType()
* @generated
*/
- int GENERATED_TYPE = 154;
+ int GENERATED_TYPE = 156;
/**
@@ -17544,6 +17636,48 @@ public interface GMFGenPackage extends EPackage {
EAttribute getPredefinedParser_ClassName();
/**
+ * Returns the meta object for class '{@link org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser <em>Predefined Enum Parser</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Predefined Enum Parser</em>'.
+ * @see org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser
+ * @generated
+ */
+ EClass getPredefinedEnumParser();
+
+ /**
+ * Returns the meta object for class '{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser <em>Ocl Choice Parser</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Ocl Choice Parser</em>'.
+ * @see org.eclipse.gmf.codegen.gmfgen.OclChoiceParser
+ * @generated
+ */
+ EClass getOclChoiceParser();
+
+ /**
+ * Returns the meta object for the reference '{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getItemsExpression <em>Items Expression</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference '<em>Items Expression</em>'.
+ * @see org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getItemsExpression()
+ * @see #getOclChoiceParser()
+ * @generated
+ */
+ EReference getOclChoiceParser_ItemsExpression();
+
+ /**
+ * Returns the meta object for the reference '{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getShowExpression <em>Show Expression</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference '<em>Show Expression</em>'.
+ * @see org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getShowExpression()
+ * @see #getOclChoiceParser()
+ * @generated
+ */
+ EReference getOclChoiceParser_ShowExpression();
+
+ /**
* Returns the meta object for class '{@link org.eclipse.gmf.codegen.gmfgen.ExpressionLabelParser <em>Expression Label Parser</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/OclChoiceParser.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/OclChoiceParser.java
new file mode 100644
index 000000000..5e914bbbd
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/OclChoiceParser.java
@@ -0,0 +1,87 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.codegen.gmfgen;
+
+/**
+ * <!-- begin-user-doc --> A representation of the model object '
+ * <em><b>Ocl Choice Parser</b></em>'. <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getItemsExpression <em>Items Expression</em>}</li>
+ * <li>{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getShowExpression <em>Show Expression</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.gmf.codegen.gmfgen.GMFGenPackage#getOclChoiceParser()
+ * @model
+ * @generated
+ */
+public interface OclChoiceParser extends GenParserImplementation {
+
+ /**
+ * Returns the value of the '<em><b>Items Expression</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Items Expression</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Items Expression</em>' reference.
+ * @see #setItemsExpression(ValueExpression)
+ * @see org.eclipse.gmf.codegen.gmfgen.GMFGenPackage#getOclChoiceParser_ItemsExpression()
+ * @model
+ * @generated
+ */
+ ValueExpression getItemsExpression();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getItemsExpression <em>Items Expression</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Items Expression</em>' reference.
+ * @see #getItemsExpression()
+ * @generated
+ */
+ void setItemsExpression(ValueExpression value);
+
+ /**
+ * Returns the value of the '<em><b>Show Expression</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Show Expression</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Show Expression</em>' reference.
+ * @see #setShowExpression(ValueExpression)
+ * @see org.eclipse.gmf.codegen.gmfgen.GMFGenPackage#getOclChoiceParser_ShowExpression()
+ * @model
+ * @generated
+ */
+ ValueExpression getShowExpression();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser#getShowExpression <em>Show Expression</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Show Expression</em>' reference.
+ * @see #getShowExpression()
+ * @generated
+ */
+ void setShowExpression(ValueExpression value);
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @model kind="operation"
+ * @generated
+ */
+ String getQualifiedClassName();
+
+} // OclChoiceParser
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/PredefinedEnumParser.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/PredefinedEnumParser.java
new file mode 100644
index 000000000..1859dbba8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/PredefinedEnumParser.java
@@ -0,0 +1,29 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.codegen.gmfgen;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Predefined Enum Parser</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ *
+ * @see org.eclipse.gmf.codegen.gmfgen.GMFGenPackage#getPredefinedEnumParser()
+ * @model
+ * @generated
+ */
+public interface PredefinedEnumParser extends GenParserImplementation {
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @model kind="operation"
+ * @generated
+ */
+ String getQualifiedClassName();
+} // PredefinedEnumParser
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenFactoryImpl.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenFactoryImpl.java
index 40935e08f..25234ac3b 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenFactoryImpl.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenFactoryImpl.java
@@ -156,6 +156,8 @@ public class GMFGenFactoryImpl extends EFactoryImpl implements GMFGenFactory {
case GMFGenPackage.GEN_APPLICATION: return createGenApplication();
case GMFGenPackage.GEN_PARSERS: return createGenParsers();
case GMFGenPackage.PREDEFINED_PARSER: return createPredefinedParser();
+ case GMFGenPackage.PREDEFINED_ENUM_PARSER: return createPredefinedEnumParser();
+ case GMFGenPackage.OCL_CHOICE_PARSER: return createOclChoiceParser();
case GMFGenPackage.EXPRESSION_LABEL_PARSER: return createExpressionLabelParser();
case GMFGenPackage.CUSTOM_PARSER: return createCustomParser();
case GMFGenPackage.EXTERNAL_PARSER: return createExternalParser();
@@ -1219,6 +1221,26 @@ public class GMFGenFactoryImpl extends EFactoryImpl implements GMFGenFactory {
* <!-- end-user-doc -->
* @generated
*/
+ public PredefinedEnumParser createPredefinedEnumParser() {
+ PredefinedEnumParserImpl predefinedEnumParser = new PredefinedEnumParserImpl();
+ return predefinedEnumParser;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public OclChoiceParser createOclChoiceParser() {
+ OclChoiceParserImpl oclChoiceParser = new OclChoiceParserImpl();
+ return oclChoiceParser;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public ExpressionLabelParser createExpressionLabelParser() {
ExpressionLabelParserImpl expressionLabelParser = new ExpressionLabelParserImpl();
return expressionLabelParser;
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
index dd4f8738f..ce777bda9 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/GMFGenPackageImpl.java
@@ -1003,6 +1003,20 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
* <!-- end-user-doc -->
* @generated
*/
+ private EClass predefinedEnumParserEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass oclChoiceParserEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
private EClass expressionLabelParserEClass = null;
/**
@@ -7036,9 +7050,51 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
* <!-- end-user-doc -->
* @generated
*/
+ public EClass getPredefinedEnumParser() {
+ if (predefinedEnumParserEClass == null) {
+ predefinedEnumParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(152);
+ }
+ return predefinedEnumParserEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getOclChoiceParser() {
+ if (oclChoiceParserEClass == null) {
+ oclChoiceParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(153);
+ }
+ return oclChoiceParserEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getOclChoiceParser_ItemsExpression() {
+ return (EReference)getOclChoiceParser().getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getOclChoiceParser_ShowExpression() {
+ return (EReference)getOclChoiceParser().getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getExpressionLabelParser() {
if (expressionLabelParserEClass == null) {
- expressionLabelParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(152);
+ expressionLabelParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(154);
}
return expressionLabelParserEClass;
}
@@ -7095,7 +7151,7 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
*/
public EClass getCustomParser() {
if (customParserEClass == null) {
- customParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(153);
+ customParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(155);
}
return customParserEClass;
}
@@ -7125,7 +7181,7 @@ public class GMFGenPackageImpl extends EPackageImpl implements GMFGenPackage {
*/
public EClass getExternalParser() {
if (externalParserEClass == null) {
- externalParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(154);
+ externalParserEClass = (EClass)EPackage.Registry.INSTANCE.getEPackage(GMFGenPackage.eNS_URI).getEClassifiers().get(156);
}
return externalParserEClass;
}
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/OclChoiceParserImpl.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/OclChoiceParserImpl.java
new file mode 100644
index 000000000..e5770be07
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/OclChoiceParserImpl.java
@@ -0,0 +1,233 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.codegen.gmfgen.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+
+import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
+import org.eclipse.gmf.codegen.gmfgen.OclChoiceParser;
+import org.eclipse.gmf.codegen.gmfgen.ValueExpression;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Ocl Choice Parser</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.gmf.codegen.gmfgen.impl.OclChoiceParserImpl#getItemsExpression <em>Items Expression</em>}</li>
+ * <li>{@link org.eclipse.gmf.codegen.gmfgen.impl.OclChoiceParserImpl#getShowExpression <em>Show Expression</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class OclChoiceParserImpl extends GenParserImplementationImpl implements OclChoiceParser {
+ /**
+ * The cached value of the '{@link #getItemsExpression() <em>Items Expression</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getItemsExpression()
+ * @generated
+ * @ordered
+ */
+ protected ValueExpression itemsExpression;
+
+ /**
+ * The cached value of the '{@link #getShowExpression() <em>Show Expression</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getShowExpression()
+ * @generated
+ * @ordered
+ */
+ protected ValueExpression showExpression;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected OclChoiceParserImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return GMFGenPackage.eINSTANCE.getOclChoiceParser();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ValueExpression getItemsExpression() {
+ if (itemsExpression != null && itemsExpression.eIsProxy()) {
+ InternalEObject oldItemsExpression = (InternalEObject)itemsExpression;
+ itemsExpression = (ValueExpression)eResolveProxy(oldItemsExpression);
+ if (itemsExpression != oldItemsExpression) {
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, GMFGenPackage.OCL_CHOICE_PARSER__ITEMS_EXPRESSION, oldItemsExpression, itemsExpression));
+ }
+ }
+ return itemsExpression;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ValueExpression basicGetItemsExpression() {
+ return itemsExpression;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setItemsExpression(ValueExpression newItemsExpression) {
+ ValueExpression oldItemsExpression = itemsExpression;
+ itemsExpression = newItemsExpression;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, GMFGenPackage.OCL_CHOICE_PARSER__ITEMS_EXPRESSION, oldItemsExpression, itemsExpression));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ValueExpression getShowExpression() {
+ if (showExpression != null && showExpression.eIsProxy()) {
+ InternalEObject oldShowExpression = (InternalEObject)showExpression;
+ showExpression = (ValueExpression)eResolveProxy(oldShowExpression);
+ if (showExpression != oldShowExpression) {
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, GMFGenPackage.OCL_CHOICE_PARSER__SHOW_EXPRESSION, oldShowExpression, showExpression));
+ }
+ }
+ return showExpression;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ValueExpression basicGetShowExpression() {
+ return showExpression;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setShowExpression(ValueExpression newShowExpression) {
+ ValueExpression oldShowExpression = showExpression;
+ showExpression = newShowExpression;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, GMFGenPackage.OCL_CHOICE_PARSER__SHOW_EXPRESSION, oldShowExpression, showExpression));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * This method returns the FQN of one of the existing classes, in particular,
+ * either 'org.eclipse.gmf.tooling.runtime.parsers.OclChoiceParser' or 'org.eclipse.gmf.tooling.runtime.parsers.OclTrackerChoiceParser'
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
+ public String getQualifiedClassName() {
+ final String packageName = "org.eclipse.gmf.tooling.runtime.parsers"; //$NON-NLS-1$
+ final String className = getShowExpression() == null ? "OclChoiceParser" : "OclTrackerChoiceParser"; //$NON-NLS-1$ //$NON-NLS-2$
+ return packageName + '.' + className;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case GMFGenPackage.OCL_CHOICE_PARSER__ITEMS_EXPRESSION:
+ if (resolve) return getItemsExpression();
+ return basicGetItemsExpression();
+ case GMFGenPackage.OCL_CHOICE_PARSER__SHOW_EXPRESSION:
+ if (resolve) return getShowExpression();
+ return basicGetShowExpression();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case GMFGenPackage.OCL_CHOICE_PARSER__ITEMS_EXPRESSION:
+ setItemsExpression((ValueExpression)newValue);
+ return;
+ case GMFGenPackage.OCL_CHOICE_PARSER__SHOW_EXPRESSION:
+ setShowExpression((ValueExpression)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case GMFGenPackage.OCL_CHOICE_PARSER__ITEMS_EXPRESSION:
+ setItemsExpression((ValueExpression)null);
+ return;
+ case GMFGenPackage.OCL_CHOICE_PARSER__SHOW_EXPRESSION:
+ setShowExpression((ValueExpression)null);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case GMFGenPackage.OCL_CHOICE_PARSER__ITEMS_EXPRESSION:
+ return itemsExpression != null;
+ case GMFGenPackage.OCL_CHOICE_PARSER__SHOW_EXPRESSION:
+ return showExpression != null;
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //OclChoiceParserImpl
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/PredefinedEnumParserImpl.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/PredefinedEnumParserImpl.java
new file mode 100644
index 000000000..53193bdfd
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/impl/PredefinedEnumParserImpl.java
@@ -0,0 +1,54 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.codegen.gmfgen.impl;
+
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.gmf.codegen.gmfgen.GMFGenPackage;
+import org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Predefined Enum Parser</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * </p>
+ *
+ * @generated
+ */
+public class PredefinedEnumParserImpl extends GenParserImplementationImpl implements PredefinedEnumParser {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected PredefinedEnumParserImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return GMFGenPackage.eINSTANCE.getPredefinedEnumParser();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
+ public String getQualifiedClassName() {
+ final String className = "EnumParser";
+ final String packageName = "org.eclipse.gmf.tooling.runtime.parsers";
+ return packageName + '.' + className;
+ }
+
+} //PredefinedEnumParserImpl
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenAdapterFactory.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenAdapterFactory.java
index cd9b06264..8fc4b354c 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenAdapterFactory.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenAdapterFactory.java
@@ -613,6 +613,14 @@ public class GMFGenAdapterFactory extends AdapterFactoryImpl {
return createPredefinedParserAdapter();
}
@Override
+ public Adapter casePredefinedEnumParser(PredefinedEnumParser object) {
+ return createPredefinedEnumParserAdapter();
+ }
+ @Override
+ public Adapter caseOclChoiceParser(OclChoiceParser object) {
+ return createOclChoiceParserAdapter();
+ }
+ @Override
public Adapter caseExpressionLabelParser(ExpressionLabelParser object) {
return createExpressionLabelParserAdapter();
}
@@ -2507,6 +2515,34 @@ public class GMFGenAdapterFactory extends AdapterFactoryImpl {
}
/**
+ * Creates a new adapter for an object of class '{@link org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser <em>Predefined Enum Parser</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.gmf.codegen.gmfgen.PredefinedEnumParser
+ * @generated
+ */
+ public Adapter createPredefinedEnumParserAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link org.eclipse.gmf.codegen.gmfgen.OclChoiceParser <em>Ocl Choice Parser</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.gmf.codegen.gmfgen.OclChoiceParser
+ * @generated
+ */
+ public Adapter createOclChoiceParserAdapter() {
+ return null;
+ }
+
+ /**
* Creates a new adapter for an object of class '{@link org.eclipse.gmf.codegen.gmfgen.ExpressionLabelParser <em>Expression Label Parser</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenSwitch.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenSwitch.java
index d846d518e..e0eb65b59 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenSwitch.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/gmfgen/util/GMFGenSwitch.java
@@ -1035,6 +1035,20 @@ public class GMFGenSwitch<T> extends Switch<T> {
if (result == null) result = defaultCase(theEObject);
return result;
}
+ case GMFGenPackage.PREDEFINED_ENUM_PARSER: {
+ PredefinedEnumParser predefinedEnumParser = (PredefinedEnumParser)theEObject;
+ T result = casePredefinedEnumParser(predefinedEnumParser);
+ if (result == null) result = caseGenParserImplementation(predefinedEnumParser);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case GMFGenPackage.OCL_CHOICE_PARSER: {
+ OclChoiceParser oclChoiceParser = (OclChoiceParser)theEObject;
+ T result = caseOclChoiceParser(oclChoiceParser);
+ if (result == null) result = caseGenParserImplementation(oclChoiceParser);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
case GMFGenPackage.EXPRESSION_LABEL_PARSER: {
ExpressionLabelParser expressionLabelParser = (ExpressionLabelParser)theEObject;
T result = caseExpressionLabelParser(expressionLabelParser);
@@ -3056,6 +3070,36 @@ public class GMFGenSwitch<T> extends Switch<T> {
}
/**
+ * Returns the result of interpreting the object as an instance of '<em>Predefined Enum Parser</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Predefined Enum Parser</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T casePredefinedEnumParser(PredefinedEnumParser object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of '<em>Ocl Choice Parser</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Ocl Choice Parser</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseOclChoiceParser(OclChoiceParser object) {
+ return null;
+ }
+
+ /**
* Returns the result of interpreting the object as an instance of '<em>Expression Label Parser</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
index cd5159ddd..8b6f72ccd 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/codegen/util/Generator.java
@@ -506,6 +506,8 @@ public class Generator extends GeneratorBase implements Runnable {
if (pi instanceof PredefinedParser) {
needsAbstractParser = true;
doGenerateJavaClass(myEmitters.getPredefinedParserEmitter(), ((PredefinedParser) pi).getQualifiedClassName(), pi);
+ } else if (pi instanceof PredefinedEnumParser) {
+ needsAbstractParser = true;
} else if (pi instanceof CustomParser && ((CustomParser) pi).isGenerateBoilerplate()) {
doGenerateJavaClass(myEmitters.getCustomParserEmitter(), ((CustomParser) pi).getQualifiedName(), pi);
} else if (pi instanceof ExpressionLabelParser) {
diff --git a/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/ChoiceUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/ChoiceUtils.qvto
new file mode 100644
index 000000000..ffa2f0ba8
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/ChoiceUtils.qvto
@@ -0,0 +1,44 @@
+modeltype gmfgen uses "http://www.eclipse.org/gmf/2009/GenModel";
+modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
+
+library Utils;
+
+
+helper gmfgen::GenCommonBase::isOclChoiceLabel() : Boolean {
+ return let labelModelFacet : gmfgen::LabelModelFacet
+ = if self.oclIsKindOf(gmfgen::GenChildLabelNode) then self.oclAsType(gmfgen::GenChildLabelNode).labelModelFacet
+ else (if self.oclIsKindOf(gmfgen::GenLabel) then self.oclAsType(gmfgen::GenLabel).modelFacet
+ else null
+ endif)
+ endif
+ in (labelModelFacet <> null)
+ and labelModelFacet.parser.oclIsKindOf(gmfgen::OclChoiceParser);
+}
+
+helper gmfgen::GenCommonBase::isOclChoiceLabelWithShowExpr() : Boolean {
+ return let labelModelFacet : gmfgen::LabelModelFacet
+ = if self.oclIsKindOf(gmfgen::GenChildLabelNode) then self.oclAsType(gmfgen::GenChildLabelNode).labelModelFacet
+ else (if self.oclIsKindOf(gmfgen::GenLabel) then self.oclAsType(gmfgen::GenLabel).modelFacet
+ else null
+ endif)
+ endif
+ in (labelModelFacet <> null)
+ and labelModelFacet.parser.oclIsKindOf(gmfgen::OclChoiceParser)
+ and (labelModelFacet.parser.oclAsType(gmfgen::OclChoiceParser).showExpression <> null);
+}
+
+helper isChoiceLabel(modelFacet : gmfgen::LabelModelFacet) : Boolean {
+ return modelFacet.parser.oclIsKindOf(gmfgen::PredefinedEnumParser)
+ or modelFacet.parser.oclIsKindOf(gmfgen::OclChoiceParser);
+}
+
+helper getDirectManagerFQN(modelFacet : gmfgen::LabelModelFacet) : String {
+ return
+ (if isChoiceLabel(modelFacet) then
+ -- 'org.eclipse.gmf.runtime.diagram.ui.tools.ComboDirectEditManager'
+ 'org.eclipse.gmf.tooling.runtime.directedit.ComboDirectEditManager'
+ else
+ -- 'org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager'
+ 'org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2'
+ endif);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/TextAware.xpt b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/TextAware.xpt
index e40da6460..0ceb958de 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/TextAware.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/impl/diagram/editparts/TextAware.xpt
@@ -13,6 +13,7 @@
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«EXTENSION xpt::diagram::ViewmapAttributesUtils»
+«EXTENSION impl::diagram::editparts::ChoiceUtils»
«DEFINE fields FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
@@ -21,8 +22,13 @@
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.common.ui.services.parser.IParser parser;
+ «IF isOclChoiceLabel()-»
«EXPAND xpt::Common::generatedMemberComment»
- private «EXPAND CodeStyle::G('java.util.List', '?')» parserElements;
+ private org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker.Registrator myOclRegistrator;
+ «ELSE-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «EXPAND CodeStyle::G('java.util.List', '?')» parserElements;
+ «ENDIF-»
«EXPAND xpt::Common::generatedMemberComment»
private String defaultText;
@@ -64,17 +70,19 @@
«EXPAND getParser(modelFacet, diagram, host)-»
- «EXPAND getManager(diagram)-»
+ «EXPAND getManager(diagram, modelFacet)-»
«EXPAND setManager-»
«EXPAND performDirectEdit-»
- «EXPAND performDirectEditAtPoint-»
-
+ «EXPAND performDirectEditAtPoint(modelFacet)-»
+
+«IF not(isChoiceLabel(modelFacet))-»
«EXPAND performDirectEditWithInitialChar-»
+«ENDIF»
- «EXPAND performDirectEditRequest-»
+ «EXPAND performDirectEditRequest(modelFacet)-»
«EXPAND refreshVisuals(needsRefreshBounds)-»
@@ -95,6 +103,14 @@
«EXPAND getAccessibleEditPart-»
«EXPAND getFontStyleOwnerView(viewmap)-»
+
+«IF isOclChoiceLabelWithShowExpr()-»
+ «EXPAND getOclTracker-»
+«ENDIF-»
+
+«IF isOclChoiceLabel()-»
+ «EXPAND getOclRegistrator-»
+«ENDIF-»
«ENDDEFINE»
«DEFINE labelSetterName FOR gmfgen::ParentAssignedViewmap-»
@@ -331,12 +347,12 @@
}
«ENDDEFINE»
-«DEFINE getManager(diagram : gmfgen::GenDiagram) FOR gmfgen::GenCommonBase-»
+«DEFINE getManager(diagram : gmfgen::GenDiagram, modelFacet : gmfgen::LabelModelFacet) FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gef.tools.DirectEditManager getManager() {
if (manager == null) {
- setManager(new org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager(this,
- org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager.getTextCellEditorClass(this),
+ setManager(new «getDirectManagerFQN(modelFacet)»(this,
+ null,
«diagram.getEditPartFactoryQualifiedClassName()».getTextCellEditorLocator(this)));
}
return manager;
@@ -357,11 +373,11 @@
}
«ENDDEFINE»
-«DEFINE performDirectEditAtPoint FOR gmfgen::GenCommonBase-»
+«DEFINE performDirectEditAtPoint(modelFacet : gmfgen::LabelModelFacet) FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected void performDirectEdit(org.eclipse.draw2d.geometry.Point eventLocation) {
- if (getManager().getClass() == org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager.class) {
- ((org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint());
+ if (getManager().getClass() == «getDirectManagerFQN(modelFacet)».class) {
+ ((«getDirectManagerFQN(modelFacet)») getManager()).show(eventLocation.getSWTPoint());
}
}
«ENDDEFINE»
@@ -371,13 +387,17 @@
private void performDirectEdit(char initialCharacter) {
if (getManager() instanceof org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) {
((org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager) getManager()).show(initialCharacter);
- } else {
+ } else //
+ if (getManager() instanceof org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2) {
+ ((org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
performDirectEdit();
}
}
«ENDDEFINE»
-«DEFINE performDirectEditRequest FOR gmfgen::GenCommonBase-»
+«DEFINE performDirectEditRequest(modelFacet : gmfgen::LabelModelFacet) FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected void performDirectEditRequest(org.eclipse.gef.Request request) {
final org.eclipse.gef.Request theRequest = request;
@@ -386,10 +406,11 @@
public void run() {
if (isActive() && isEditable()) {
+ «IF not(isChoiceLabel(modelFacet))-»
if (theRequest.getExtendedData().get(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
Character initialChar = (Character) theRequest.getExtendedData().get(org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
performDirectEdit(initialChar.charValue());
- } else if ((theRequest instanceof org.eclipse.gef.requests.DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ } else «ENDIF» if ((theRequest instanceof org.eclipse.gef.requests.DirectEditRequest) && (getEditText().equals(getLabelText()))) {
org.eclipse.gef.requests.DirectEditRequest editRequest = (org.eclipse.gef.requests.DirectEditRequest) theRequest;
performDirectEdit(editRequest.getLocation());
} else {
@@ -485,6 +506,16 @@
«DEFINE addSemanticListeners FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected void addSemanticListeners() {
+«IF isOclChoiceLabel()-»
+ «IF isOclChoiceLabelWithShowExpr()-»
+ org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker tracker = getTracker();
+ tracker.initialize(resolveSemanticElement());
+ tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
+ «ELSE-»
+ super.addSemanticListeners();
+ «ENDIF-»
+ ((org.eclipse.gmf.tooling.runtime.parsers.OclChoiceParser) getParser()).installListeners(this, getOclRegistrator());
+«ELSE-»
if (getParser() instanceof org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) {
org.eclipse.emf.ecore.EObject element = resolveSemanticElement();
parserElements = ((org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
@@ -494,12 +525,21 @@
} else {
super.addSemanticListeners();
}
+«ENDIF-»
}
«ENDDEFINE»
«DEFINE removeSemanticListeners FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected void removeSemanticListeners() {
+«IF isOclChoiceLabel()-»
+ ((org.eclipse.gmf.tooling.runtime.parsers.OclChoiceParser) getParser()).uninstallListeners();
+ «IF isOclChoiceLabelWithShowExpr()-»
+ getTracker().uninstallListeners();
+ «ELSE-»
+ super.removeSemanticListeners();
+ «ENDIF-»
+«ELSE-»
if (parserElements != null) {
for (int i = 0; i < parserElements.size(); i++) {
removeListenerFilter("SemanticModel" + i); «EXPAND xpt::Common::nonNLS»
@@ -507,6 +547,7 @@
} else {
super.removeSemanticListeners();
}
+«ENDIF-»
}
«ENDDEFINE»
@@ -534,4 +575,32 @@
return getPrimaryView();
«ENDIF-»
}
-«ENDDEFINE» \ No newline at end of file
+«ENDDEFINE»
+
+«DEFINE getOclTracker FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker getTracker() {
+ return ((org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker) getParser()).getOclTracker();
+ }
+«ENDDEFINE»
+
+«DEFINE getOclRegistrator FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker.Registrator getOclRegistrator() {
+ if (myOclRegistrator == null) {
+ myOclRegistrator = new org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker.Registrator() {
+
+ @Override
+ public void registerListener(String filterId, org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener listener, org.eclipse.emf.ecore.EObject element) {
+ addListenerFilter(filterId, listener, element);
+ }
+
+ @Override
+ public void unregisterListener(String filterId) {
+ removeListenerFilter(filterId);
+ }
+ };
+ }
+ return myOclRegistrator;
+ }
+«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt
index 06f445d25..6ddcaf761 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt
@@ -14,7 +14,8 @@
*/
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
-
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
«EXTENSION xpt::providers::ParserUtils»
«DEFINE accessorMethod_delegate2providers FOR gmfgen::GenParsers-»
@@ -144,17 +145,28 @@ org.eclipse.gmf.runtime.common.ui.services.parser.ParserService.getInstance().ge
«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::ExternalParser»«REM»NOTHING TO DO«ENDREM»«ENDDEFINE»
«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::PredefinedParser-»
- «EXPAND xpt::Common::caseVisualID FOR element» return «parserAccessorName(element)»();
+ «EXPAND _doGetParser(element)-»
+«ENDDEFINE»
+
+«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::PredefinedEnumParser»
+ «EXPAND _doGetParser(element)-»
+«ENDDEFINE»
+
+«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::OclChoiceParser»
+ «EXPAND _doGetParser(element)-»
«ENDDEFINE»
«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::CustomParser-»
- «EXPAND xpt::Common::caseVisualID FOR element» return «parserAccessorName(element)»();
+ «EXPAND _doGetParser(element)-»
«ENDDEFINE»
«DEFINE _getParser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::ExpressionLabelParser-»
- «EXPAND xpt::Common::caseVisualID FOR element» return «parserAccessorName(element)»();
+ «EXPAND _doGetParser(element)-»
«ENDDEFINE»
+«DEFINE _doGetParser(element : gmfgen::GenCommonBase) FOR gmfgen::GenParserImplementation-»
+ «EXPAND xpt::Common::caseVisualID FOR element» return «parserAccessorName(element)»();
+«ENDDEFINE»
«DEFINE parsers FOR gmfgen::GenNode»«EXPAND _parser FOREACH labels»«ENDDEFINE»
«DEFINE parsers FOR gmfgen::GenLink»«EXPAND _parser FOREACH labels»«ENDDEFINE»
@@ -183,12 +195,36 @@ org.eclipse.gmf.runtime.common.ui.services.parser.ParserService.getInstance().ge
«ENDDEFINE»
«DEFINE _parser(modelFacet : gmfgen::FeatureLabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::PredefinedParser»
+ «EXPAND _predefinedParser(modelFacet, element)»
+«ENDDEFINE»
+
+«DEFINE _parser(modelFacet : gmfgen::FeatureLabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::PredefinedEnumParser»
+ «EXPAND _predefinedParser(modelFacet, element)»
+«ENDDEFINE»
+
+«DEFINE _parser(modelFacet : gmfgen::FeatureLabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::OclChoiceParser»
+ «EXPAND _predefinedParser(modelFacet, element)»
+«ENDDEFINE»
+
+«DEFINE _predefinedParser(modelFacet : gmfgen::FeatureLabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::GenParserImplementation»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.common.ui.services.parser.IParser «parserFieldName(element)»;
«EXPAND xpt::Common::generatedMemberComment»
«IF holder.extensibleViaService»private«ELSE»public«ENDIF» org.eclipse.gmf.runtime.common.ui.services.parser.IParser «parserAccessorName(element)»() {
if («parserFieldName(element)» == null) {
+ «EXPAND _createPredefinedParser(modelFacet, 'parser')-»
+ «parserFieldName(element)» = parser;
+ }
+ return «parserFieldName(element)»;
+ }
+«ENDDEFINE»
+
+«DEFINE _createPredefinedParser(modelFacet : gmfgen::FeatureLabelModelFacet, parserVar : String) FOR gmfgen::GenParserImplementation»
+ «ERROR 'PredefinedParser, PredefinedEnumParser or OclChoiceParser expected but occured: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE _createPredefinedParser(modelFacet : gmfgen::FeatureLabelModelFacet, parserVar : String) FOR gmfgen::PredefinedParser»
org.eclipse.emf.ecore.EAttribute[] features = new org.eclipse.emf.ecore.EAttribute[] {
«EXPAND MetaModel::MetaFeature FOREACH modelFacet.metaFeatures SEPARATOR ', ' »
};
@@ -197,12 +233,50 @@ org.eclipse.gmf.runtime.common.ui.services.parser.ParserService.getInstance().ge
«EXPAND MetaModel::MetaFeature FOREACH modelFacet.editableMetaFeatures SEPARATOR ', '»
};
«ENDIF-»
- «getQualifiedClassName()» parser = new «getQualifiedClassName()»(features«IF modelFacet.editableMetaFeatures->size() > 0», editableFeatures«ENDIF»);
- «EXPAND _setPatterns(viewMethod, editMethod, 'parser') FOR modelFacet-»
- «parserFieldName(element)» = parser;
- }
- return «parserFieldName(element)»;
- }
+ «getQualifiedClassName()» «parserVar» = new «getQualifiedClassName()»(features«IF modelFacet.editableMetaFeatures->size() > 0», editableFeatures«ENDIF»);
+ «EXPAND _setPatterns(viewMethod, editMethod, parserVar) FOR modelFacet-»
+«ENDDEFINE»
+
+«DEFINE _createPredefinedParser(modelFacet : gmfgen::FeatureLabelModelFacet, parserVar : String) FOR gmfgen::PredefinedEnumParser»
+ org.eclipse.emf.ecore.EAttribute editableFeature = «EXPAND MetaModel::MetaFeature FOR modelFacet.editableMetaFeatures->first()»;
+ «getQualifiedClassName()» «parserVar» = new «getQualifiedClassName()»(editableFeature);
+«ENDDEFINE»
+
+«DEFINE _createPredefinedParser(modelFacet : gmfgen::FeatureLabelModelFacet, parserVar : String) FOR gmfgen::OclChoiceParser»
+ «LET modelFacet.editableMetaFeatures->first() AS feature-»
+ org.eclipse.emf.ecore.EStructuralFeature editableFeature = «EXPAND MetaModel::MetaFeature FOR feature»;
+ «LET feature.genClass AS context-»
+ org.eclipse.gmf.tooling.runtime.parsers.ChoiceParserBase «parserVar» = «-»
+ «IF showExpression <> null-»
+ new org.eclipse.gmf.tooling.runtime.parsers.OclTrackerChoiceParser( //
+ editableFeature «-»
+ , «EXPAND _safeItemExpression(feature)-»
+ , «EXPAND xpt::expressions::getExpression::getExpressionBody FOR showExpression-»
+ , «holder.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory()«-»
+ «EXPAND _optionalOclTrackerFactoryTypeHint FOR showExpression-»
+ );
+ «ELSE-»
+ new org.eclipse.gmf.tooling.runtime.parsers.OclChoiceParser( //
+ editableFeature «-»
+ , «EXPAND _safeItemExpression(feature)-»
+ , null «-»
+ , «holder.editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory()«-»
+ );
+ «ENDIF-»
+ «ENDLET-»
+ «ENDLET-»
+«ENDDEFINE»
+
+«DEFINE _safeItemExpression(feature : genmodel::GenFeature) FOR gmfgen::OclChoiceParser-»
+ «IF itemsExpression = null-»
+ "«feature.ecoreFeature.eType.name».allInstances()"«-»
+ «ELSE-»
+ «EXPAND xpt::expressions::getExpression::getExpressionBody FOR itemsExpression-»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE _optionalOclTrackerFactoryTypeHint FOR gmfgen::ValueExpression-»
+«IF body.startsWith('--IA')», org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory.Type.IMPACT_ANALYZER«ENDIF-»
«ENDDEFINE»
«DEFINE _setPatterns(viewMethod : gmfgen::LabelTextAccessMethod, editMethod : gmfgen::LabelTextAccessMethod, parserVar : String) FOR gmfgen::FeatureLabelModelFacet-»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/EditPartFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/EditPartFactory.xpt
index 5730cadf4..6b63143f8 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/EditPartFactory.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editparts/EditPartFactory.xpt
@@ -73,19 +73,19 @@ public class «editPartFactoryClassName» implements org.eclipse.gef.EditPartFac
«EXPAND xpt::Common::generatedMemberComment»
public void relocate(org.eclipse.jface.viewers.CellEditor celleditor) {
- org.eclipse.swt.widgets.Text text = (org.eclipse.swt.widgets.Text) celleditor.getControl();
+ org.eclipse.swt.widgets.Control control = (org.eclipse.swt.widgets.Control) celleditor.getControl();
org.eclipse.draw2d.geometry.Rectangle rect = getWrapLabel().getTextBounds().getCopy();
getWrapLabel().translateToAbsolute(rect);
- if (!text.getFont().isDisposed()) {
+ if (!control.getFont().isDisposed()) {
if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) {
- rect.setSize(new org.eclipse.draw2d.geometry.Dimension(text.computeSize(rect.width, org.eclipse.swt.SWT.DEFAULT)));
+ rect.setSize(new org.eclipse.draw2d.geometry.Dimension(control.computeSize(rect.width, org.eclipse.swt.SWT.DEFAULT)));
} else {
- int avr = org.eclipse.draw2d.FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
- rect.setSize(new org.eclipse.draw2d.geometry.Dimension(text.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
+ int avr = org.eclipse.draw2d.FigureUtilities.getFontMetrics(control.getFont()).getAverageCharWidth();
+ rect.setSize(new org.eclipse.draw2d.geometry.Dimension(control.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
}
}
- if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(text.getBounds()))) {
- text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(control.getBounds()))) {
+ control.setBounds(rect.x, rect.y, rect.width, rect.height);
}
}
}
@@ -108,15 +108,15 @@ public class «editPartFactoryClassName» implements org.eclipse.gef.EditPartFac
«EXPAND xpt::Common::generatedMemberComment»
public void relocate(org.eclipse.jface.viewers.CellEditor celleditor) {
- org.eclipse.swt.widgets.Text text = (org.eclipse.swt.widgets.Text) celleditor.getControl();
+ org.eclipse.swt.widgets.Control control = (org.eclipse.swt.widgets.Control) celleditor.getControl();
org.eclipse.draw2d.geometry.Rectangle rect = getLabel().getTextBounds().getCopy();
getLabel().translateToAbsolute(rect);
- if (!text.getFont().isDisposed()) {
- int avr = org.eclipse.draw2d.FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
- rect.setSize(new org.eclipse.draw2d.geometry.Dimension(text.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
+ if (!control.getFont().isDisposed()) {
+ int avr = org.eclipse.draw2d.FigureUtilities.getFontMetrics(control.getFont()).getAverageCharWidth();
+ rect.setSize(new org.eclipse.draw2d.geometry.Dimension(control.computeSize(org.eclipse.swt.SWT.DEFAULT, org.eclipse.swt.SWT.DEFAULT)).expand(avr * 2, 0));
}
- if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(text.getBounds()))) {
- text.setBounds(rect.x, rect.y, rect.width, rect.height);
+ if (!rect.equals(new org.eclipse.draw2d.geometry.Rectangle(control.getBounds()))) {
+ control.setBounds(rect.x, rect.y, rect.width, rect.height);
}
}
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/AbstractExpression.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/AbstractExpression.xpt
index 843def10e..843def10e 100755..100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/AbstractExpression.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/AbstractExpression.xpt
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/OCLExpressionFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/OCLExpressionFactory.xpt
index d4312d09f..e0e7b729e 100755..100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/OCLExpressionFactory.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/OCLExpressionFactory.xpt
@@ -116,10 +116,31 @@ org.eclipse.ocl.options.ParsingOptions.setOption(«environmentVar», org.eclipse
«DEFINE _initInterpreterFactory FOR gmfgen::GenExpressionInterpreter-»
«EXPAND xpt::Common::generatedMemberComment»
private final «container.getAbstractExpressionQualifiedClassName()»[] expressions;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final String [] expressionBodies;
«EXPAND xpt::Common::generatedMemberComment»
protected «className»() {
this.expressions = new «container.getAbstractExpressionQualifiedClassName()»[«expressions->size()»];
+ this.expressionBodies = new String[] {
+ «FOREACH expressions.getBodyString() AS b»«b», «EXPAND xpt::Common::nonNLS»
+ «ENDFOREACH-»
+ };
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private static «className» getInstance() {
+ «className» instance = «EXPAND plugin::Activator::instanceAccess FOR container.editorGen».get«className»();
+ if (instance == null) {
+ «EXPAND plugin::Activator::instanceAccess FOR container.editorGen».set«className»(instance = new «className»());
+ }
+ return instance;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public static String getExpressionBody(int index) {
+ return getInstance().expressionBodies[index];
}
«EXPAND xpt::Common::generatedMemberComment»
@@ -133,19 +154,12 @@ org.eclipse.ocl.options.ParsingOptions.setOption(«environmentVar», org.eclipse
reuse an expression (and change DGMT#bindToProvider accordingly), then the answer to previous point would become obvious (i.e. "body is enough")
«ENDREM-»
public static «container.getAbstractExpressionQualifiedClassName()» getExpression(int index, org.eclipse.emf.ecore.EClassifier context, java.util.Map«EXPAND CodeStyle::G2('String', 'org.eclipse.emf.ecore.EClassifier') FOR container.editorGen.diagram» environment) {
- «className» cached = «EXPAND plugin::Activator::instanceAccess FOR container.editorGen».get«className»();
- if (cached == null) {
- «EXPAND plugin::Activator::instanceAccess FOR container.editorGen».set«className»(cached = new «className»());
- }
+ «className» cached = getInstance();
if (index < 0 || index >= cached.expressions.length) {
throw new IllegalArgumentException();
}
- if (cached.expressions[index] == null) {
- final String[] exprBodies = new String[] {
- «FOREACH expressions.getBodyString() AS b»«b», «EXPAND xpt::Common::nonNLS»
- «ENDFOREACH-»
- };
- cached.expressions[index] = getExpression(exprBodies[index], context, environment == null ? «EXPAND CodeStyle::emptyMap('String, org.eclipse.emf.ecore.EClassifier') FOR container.editorGen.diagram» : environment);
+ if (cached.expressions[index] == null) {
+ cached.expressions[index] = getExpression(cached.expressionBodies[index], context, environment == null ? «EXPAND CodeStyle::emptyMap('String, org.eclipse.emf.ecore.EClassifier') FOR container.editorGen.diagram» : environment);
}
return cached.expressions[index];
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/RegexpExpressionFactory.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/RegexpExpressionFactory.xpt
index a42c198c0..a42c198c0 100755..100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/RegexpExpressionFactory.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/RegexpExpressionFactory.xpt
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt
index ee20b2a28..b2e0b1cac 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt
@@ -13,6 +13,20 @@
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«DEFINE getExpressionBody FOR gmfgen::ValueExpression-»
+«EXPAND getExpressionBody(self) FOR provider»
+«ENDDEFINE»
+
+«DEFINE getExpressionBody(gmfgen::ValueExpression valueExpr) FOR gmfgen::GenExpressionProviderBase»«ERROR 'Abstract template call: getExpression'»«ENDDEFINE»
+
+«DEFINE getExpressionBody(gmfgen::ValueExpression valueExpr) FOR gmfgen::GenExpressionInterpreter-»
+«getQualifiedClassName()».getExpressionBody(«expressions->indexOf(valueExpr) - 1»)«-»
+«ENDDEFINE»
+
+
+«DEFINE getExpression(gmfgen::ValueExpression valueExpr, genmodel::GenClassifier context) FOR gmfgen::GenExpressionProviderBase»«ERROR 'Abstract template call: getExpression'»«ENDDEFINE»
+
«DEFINE getExpression(gmfgen::ValueExpression valueExpr, genmodel::GenClassifier context) FOR gmfgen::GenExpressionInterpreter-»
«EXPAND getExpression(valueExpr, context, 'null')-»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateMappingEntry_labelMappings_OclChoiceLabelMapping.gif b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateMappingEntry_labelMappings_OclChoiceLabelMapping.gif
new file mode 100644
index 000000000..8883ef6af
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateMappingEntry_labelMappings_OclChoiceLabelMapping.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_Constraint.gif b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_Constraint.gif
new file mode 100644
index 000000000..28b7d50cb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_Constraint.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_ValueExpression.gif b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_ValueExpression.gif
new file mode 100644
index 000000000..967985834
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_itemsExpression_ValueExpression.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_Constraint.gif b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_Constraint.gif
new file mode 100644
index 000000000..28b7d50cb
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_Constraint.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_ValueExpression.gif b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_ValueExpression.gif
new file mode 100644
index 000000000..967985834
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map.edit/icons/full/ctool16/CreateOclChoiceLabelMapping_showExpression_ValueExpression.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.map.edit/icons/full/obj16/OclChoiceLabelMapping.gif b/plugins/org.eclipse.gmf.map.edit/icons/full/obj16/OclChoiceLabelMapping.gif
new file mode 100644
index 000000000..c8d381f0b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map.edit/icons/full/obj16/OclChoiceLabelMapping.gif
Binary files differ
diff --git a/plugins/org.eclipse.gmf.map.edit/plugin.properties b/plugins/org.eclipse.gmf.map.edit/plugin.properties
index 7cef824fe..ecfcb5742 100644
--- a/plugins/org.eclipse.gmf.map.edit/plugin.properties
+++ b/plugins/org.eclipse.gmf.map.edit/plugin.properties
@@ -244,3 +244,14 @@ _UI_ExpressionLabelMapping_editExpression_feature = Edit Expression
_UI_ExpressionLabelMapping_editExpression_description = Optional expression to produce editable string representation of the label. If not set, viewExpression is used
_UI_ExpressionLabelMapping_validateExpression_feature = Validate Expression
_UI_ExpressionLabelMapping_validateExpression_description = Boolean expression in a string context, which able to tell whether user-entered text is valid
+_UI_FeatureLabelMapping_oclChoice_feature = Ocl Choice
+_UI_OclChoiceMapping_itemsExpression_feature = Items Expression
+_UI_OclChoiceMapping_showExpression_feature = Show Expression
+_UI_OclChoiceMappingBase_type = Ocl Choice Mapping Base
+_UI_OclChoiceMappingBase_itemsExpression_feature = Items Expression
+_UI_OclChoiceMappingBase_showExpression_feature = Show Expression
+_UI_OclChoiceLabelMapping_type = Ocl Choice Label Mapping
+_UI_OclChoiceLabelMapping_refFeature_feature = Ref Feature
+_UI_OclChoiceLabelMapping_itemsExpression_feature = Items Expression
+_UI_OclChoiceLabelMapping_showExpression_feature = Show Expression
+_UI_OclChoiceLabelMapping_feature_feature = Feature
diff --git a/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/GMFMapItemProviderAdapterFactory.java b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/GMFMapItemProviderAdapterFactory.java
index edbb238ad..f14863022 100644
--- a/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/GMFMapItemProviderAdapterFactory.java
+++ b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/GMFMapItemProviderAdapterFactory.java
@@ -212,6 +212,29 @@ public class GMFMapItemProviderAdapterFactory extends GMFMapAdapterFactory imple
}
/**
+ * This keeps track of the one adapter used for all {@link org.eclipse.gmf.mappings.OclChoiceLabelMapping} instances.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected OclChoiceLabelMappingItemProvider oclChoiceLabelMappingItemProvider;
+
+ /**
+ * This creates an adapter for a {@link org.eclipse.gmf.mappings.OclChoiceLabelMapping}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Adapter createOclChoiceLabelMappingAdapter() {
+ if (oclChoiceLabelMappingItemProvider == null) {
+ oclChoiceLabelMappingItemProvider = new OclChoiceLabelMappingItemProvider(this);
+ }
+
+ return oclChoiceLabelMappingItemProvider;
+ }
+
+ /**
* This keeps track of the one adapter used for all {@link org.eclipse.gmf.mappings.DesignLabelMapping} instances.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -779,6 +802,7 @@ public class GMFMapItemProviderAdapterFactory extends GMFMapAdapterFactory imple
if (canvasMappingItemProvider != null) canvasMappingItemProvider.dispose();
if (labelMappingItemProvider != null) labelMappingItemProvider.dispose();
if (featureLabelMappingItemProvider != null) featureLabelMappingItemProvider.dispose();
+ if (oclChoiceLabelMappingItemProvider != null) oclChoiceLabelMappingItemProvider.dispose();
if (designLabelMappingItemProvider != null) designLabelMappingItemProvider.dispose();
if (expressionLabelMappingItemProvider != null) expressionLabelMappingItemProvider.dispose();
if (constraintItemProvider != null) constraintItemProvider.dispose();
diff --git a/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/MappingEntryItemProvider.java b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/MappingEntryItemProvider.java
index 093d983ea..a767fe8ae 100644
--- a/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/MappingEntryItemProvider.java
+++ b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/MappingEntryItemProvider.java
@@ -227,6 +227,11 @@ public class MappingEntryItemProvider
newChildDescriptors.add
(createChildParameter
(GMFMapPackage.eINSTANCE.getMappingEntry_LabelMappings(),
+ GMFMapFactory.eINSTANCE.createOclChoiceLabelMapping()));
+
+ newChildDescriptors.add
+ (createChildParameter
+ (GMFMapPackage.eINSTANCE.getMappingEntry_LabelMappings(),
GMFMapFactory.eINSTANCE.createDesignLabelMapping()));
newChildDescriptors.add
diff --git a/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/NodeReferenceItemProvider.java b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/NodeReferenceItemProvider.java
index 449af545f..7397d822a 100644
--- a/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/NodeReferenceItemProvider.java
+++ b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/NodeReferenceItemProvider.java
@@ -31,8 +31,9 @@ import org.eclipse.gmf.mappings.presentation.FilterUtil;
* This is the item provider adapter for a {@link org.eclipse.gmf.mappings.NodeReference} object.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
+// TODO: abstract is not generated
public abstract class NodeReferenceItemProvider
extends ItemProviderAdapter
implements
diff --git a/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/OclChoiceLabelMappingItemProvider.java b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/OclChoiceLabelMappingItemProvider.java
new file mode 100644
index 000000000..575ffbab0
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map.edit/src/org/eclipse/gmf/mappings/provider/OclChoiceLabelMappingItemProvider.java
@@ -0,0 +1,273 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.mappings.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
+import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
+import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ViewerNotification;
+import org.eclipse.gmf.mappings.GMFMapFactory;
+import org.eclipse.gmf.mappings.GMFMapPackage;
+import org.eclipse.gmf.mappings.OclChoiceLabelMapping;
+import org.eclipse.gmf.mappings.presentation.FilterUtil;
+
+/**
+ * This is the item provider adapter for a
+ * {@link org.eclipse.gmf.mappings.OclChoiceLabelMapping} object. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+public class OclChoiceLabelMappingItemProvider extends LabelMappingItemProvider implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider,
+ IItemPropertySource {
+
+ /**
+ * This constructs an instance from a factory and a notifier. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ public OclChoiceLabelMappingItemProvider(AdapterFactory adapterFactory) {
+ super(adapterFactory);
+ }
+
+ /**
+ * This returns the property descriptors for the adapted class. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public List<IItemPropertyDescriptor> getPropertyDescriptors(Object object) {
+ if (itemPropertyDescriptors == null) {
+ super.getPropertyDescriptors(object);
+
+ addFeaturePropertyDescriptor(object);
+ addItemsExpressionPropertyDescriptor(object);
+ addShowExpressionPropertyDescriptor(object);
+ }
+ return itemPropertyDescriptors;
+ }
+
+ /**
+ * This adds a property descriptor for the Feature feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ protected void addFeaturePropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add(new ItemPropertyDescriptor(((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_OclChoiceLabelMapping_feature_feature"), getString("_UI_PropertyDescriptor_description", "_UI_OclChoiceLabelMapping_feature_feature", "_UI_OclChoiceLabelMapping_type"),
+ GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_Feature(), true, false, true, null, null, null) {
+
+ protected Collection<?> getComboBoxObjects(Object object) {
+ @SuppressWarnings("unchecked")
+ Collection<EStructuralFeature> original = (Collection<EStructuralFeature>) super.getComboBoxObjects(object);
+ Collection<EStructuralFeature> filteredByContainer = FilterUtil.filterByContainerMetaclass(original, ((OclChoiceLabelMapping) object).getMapEntry());
+ Collection<EStructuralFeature> result = new ArrayList<EStructuralFeature>();
+ for (EStructuralFeature feature : filteredByContainer) {
+ if (feature instanceof EAttribute) {
+ result.add(feature);
+ } else if (feature instanceof EReference) {
+ EReference reference = (EReference) feature;
+ if (!reference.isContainment() && reference.getUpperBound() == 1) {
+ result.add(feature);
+ }
+ }
+ }
+ return result;
+ }
+ });
+ }
+
+ /**
+ * This adds a property descriptor for the Items Expression feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addItemsExpressionPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_OclChoiceLabelMapping_itemsExpression_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_OclChoiceLabelMapping_itemsExpression_feature", "_UI_OclChoiceLabelMapping_type"),
+ GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ItemsExpression(),
+ true,
+ false,
+ false,
+ null,
+ getString("_UI_VisualrepresentationPropertyCategory"),
+ null));
+ }
+
+ /**
+ * This adds a property descriptor for the Show Expression feature. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ protected void addShowExpressionPropertyDescriptor(Object object) {
+ itemPropertyDescriptors.add
+ (createItemPropertyDescriptor
+ (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_OclChoiceLabelMapping_showExpression_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_OclChoiceLabelMapping_showExpression_feature", "_UI_OclChoiceLabelMapping_type"),
+ GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ShowExpression(),
+ true,
+ false,
+ false,
+ null,
+ getString("_UI_VisualrepresentationPropertyCategory"),
+ null));
+ }
+
+ /**
+ * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
+ * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
+ * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
+ if (childrenFeatures == null) {
+ super.getChildrenFeatures(object);
+ childrenFeatures.add(GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ItemsExpression());
+ childrenFeatures.add(GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ShowExpression());
+ }
+ return childrenFeatures;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EStructuralFeature getChildFeature(Object object, Object child) {
+ // Check the type of the specified child object and return the proper feature to use for
+ // adding (see {@link AddCommand}) it as a child.
+
+ return super.getChildFeature(object, child);
+ }
+
+ /**
+ * This returns OclChoiceLabelMapping.gif.
+ * <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object getImage(Object object) {
+ return overlayImage(object, getResourceLocator().getImage("full/obj16/OclChoiceLabelMapping"));
+ }
+
+ /**
+ * This returns the label text for the adapted class.
+ * <!-- begin-user-doc
+ * --> <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String getText(Object object) {
+ OclChoiceLabelMapping oclChoiceLabelMapping = (OclChoiceLabelMapping)object;
+ return getString("_UI_OclChoiceLabelMapping_type") + " " + oclChoiceLabelMapping.isReadOnly();
+ }
+
+ /**
+ * This handles model notifications by calling {@link #updateChildren} to update any cached
+ * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}.
+ * <!-- begin-user-doc --> <!--
+ * end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void notifyChanged(Notification notification) {
+ updateChildren(notification);
+
+ switch (notification.getFeatureID(OclChoiceLabelMapping.class)) {
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION:
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION:
+ fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
+ return;
+ }
+ super.notifyChanged(notification);
+ }
+
+ /**
+ * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s
+ * describing the children that can be created under this object. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
+ super.collectNewChildDescriptors(newChildDescriptors, object);
+
+ newChildDescriptors.add
+ (createChildParameter
+ (GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ItemsExpression(),
+ GMFMapFactory.eINSTANCE.createValueExpression()));
+
+ newChildDescriptors.add
+ (createChildParameter
+ (GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ItemsExpression(),
+ GMFMapFactory.eINSTANCE.createConstraint()));
+
+ newChildDescriptors.add
+ (createChildParameter
+ (GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ShowExpression(),
+ GMFMapFactory.eINSTANCE.createValueExpression()));
+
+ newChildDescriptors.add
+ (createChildParameter
+ (GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ShowExpression(),
+ GMFMapFactory.eINSTANCE.createConstraint()));
+ }
+
+ /**
+ * This returns the label text for
+ * {@link org.eclipse.emf.edit.command.CreateChildCommand}. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ */
+ @Override
+ public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) {
+ Object childFeature = feature;
+ Object childObject = child;
+
+ boolean qualify =
+ childFeature == GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ItemsExpression() ||
+ childFeature == GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping_ShowExpression();
+
+ if (qualify) {
+ return getString
+ ("_UI_CreateChild_text2",
+ new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) });
+ }
+ return super.getCreateChildText(owner, feature, child, selection);
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.map/models/gmfmap.ecore b/plugins/org.eclipse.gmf.map/models/gmfmap.ecore
index a0eb0dcdf..7d8a4cc8e 100644
--- a/plugins/org.eclipse.gmf.map/models/gmfmap.ecore
+++ b/plugins/org.eclipse.gmf.map/models/gmfmap.ecore
@@ -243,6 +243,30 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="viewMethod" eType="#//LabelTextAccessMethod"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="editMethod" eType="#//LabelTextAccessMethod"/>
</eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="OclChoiceLabelMapping" eSuperTypes="#//LabelMapping">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="Label based on a feature (reference or attribute) from domain model and list of choices"/>
+ </eAnnotations>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="feature" lowerBound="1"
+ eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EStructuralFeature">
+ <eAnnotations source="http://www.eclipse.org/gmf/2005/constraints">
+ <details key="ocl" value="feature.eContainingClass.isSuperTypeOf(mapEntry.domainMetaElement)"/>
+ <details key="description" value="Label reference must be available in 'Domain Element' EClass of the labeled mapping entry"/>
+ </eAnnotations>
+ <eAnnotations source="http://www.eclipse.org/gmf/2005/constraints">
+ <details key="ocl" value="feature.oclIsKindOf(ecore::EReference) implies (not(feature.oclAsType(ecore::EReference).containment) and (feature.oclAsType(ecore::EReference).upperBound = 1))"/>
+ <details key="description" value="Reference feature should not be containment and don't be multiple"/>
+ </eAnnotations>
+ <eAnnotations source="http://www.eclipse.org/gmf/2005/constraints">
+ <details key="ocl" value="feature.oclIsKindOf(ecore::EAttribute) implies (itemsExpression &lt;> null)"/>
+ <details key="description" value="Items expression should be set if feature is an EAttribute"/>
+ </eAnnotations>
+ </eStructuralFeatures>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="itemsExpression" eType="#//ValueExpression"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="showExpression" eType="#//ValueExpression"
+ containment="true"/>
+ </eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="LabelTextAccessMethod">
<eLiterals name="MESSAGE_FORMAT"/>
<eLiterals name="NATIVE" value="1"/>
diff --git a/plugins/org.eclipse.gmf.map/models/gmfmap.emf b/plugins/org.eclipse.gmf.map/models/gmfmap.emf
index a38407558..2e33c1bfd 100644
--- a/plugins/org.eclipse.gmf.map/models/gmfmap.emf
+++ b/plugins/org.eclipse.gmf.map/models/gmfmap.emf
@@ -174,6 +174,16 @@ class FeatureLabelMapping extends LabelMapping {
attr LabelTextAccessMethod editMethod;
}
+@genmodel(documentation="Label based on a feature (reference or attribute) from domain model and list of choices")
+class OclChoiceLabelMapping extends LabelMapping {
+ @constraints(ocl="feature.eContainingClass.isSuperTypeOf(mapEntry.domainMetaElement)", description="Label reference must be available in 'Domain Element' EClass of the labeled mapping entry")
+ @constraints(ocl="feature.oclIsKindOf(ecore::EReference) implies (not(feature.oclAsType(ecore::EReference).containment) and (feature.oclAsType(ecore::EReference).upperBound = 1))", description="Reference feature should not be containment and don't be multiple")
+ @constraints(ocl="feature.oclIsKindOf(ecore::EAttribute) implies (itemsExpression <> null)", description="Items expression should be set if feature is an EAttribute")
+ ref ecore.EStructuralFeature[1] feature;
+ val ValueExpression[?] itemsExpression;
+ val ValueExpression[?] showExpression;
+}
+
enum LabelTextAccessMethod {
MESSAGE_FORMAT; // java.text.MessageFormat
NATIVE; // EcoreUtil.convertToString(...) / EcoreUtil.createFromString(...)
diff --git a/plugins/org.eclipse.gmf.map/models/gmfmap.genmodel b/plugins/org.eclipse.gmf.map/models/gmfmap.genmodel
index 77656acd9..040145389 100644
--- a/plugins/org.eclipse.gmf.map/models/gmfmap.genmodel
+++ b/plugins/org.eclipse.gmf.map/models/gmfmap.genmodel
@@ -114,6 +114,13 @@
<genFeatures createChild="false" propertyCategory="Visual representation" ecoreFeature="ecore:EAttribute gmfmap.ecore#//FeatureLabelMapping/viewMethod"/>
<genFeatures createChild="false" propertyCategory="Visual representation" ecoreFeature="ecore:EAttribute gmfmap.ecore#//FeatureLabelMapping/editMethod"/>
</genClasses>
+ <genClasses ecoreClass="gmfmap.ecore#//OclChoiceLabelMapping">
+ <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference gmfmap.ecore#//OclChoiceLabelMapping/feature"/>
+ <genFeatures children="true" createChild="true" propertyCategory="Visual representation"
+ ecoreFeature="ecore:EReference gmfmap.ecore#//OclChoiceLabelMapping/itemsExpression"/>
+ <genFeatures children="true" createChild="true" propertyCategory="Visual representation"
+ propertyDescription="" ecoreFeature="ecore:EReference gmfmap.ecore#//OclChoiceLabelMapping/showExpression"/>
+ </genClasses>
<genClasses ecoreClass="gmfmap.ecore#//DesignLabelMapping"/>
<genClasses ecoreClass="gmfmap.ecore#//ExpressionLabelMapping">
<genFeatures children="true" createChild="true" propertyCategory="Visual representation"
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapFactory.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapFactory.java
index db0fa2807..81cfba006 100644
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapFactory.java
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapFactory.java
@@ -80,6 +80,15 @@ public interface GMFMapFactory extends EFactory {
FeatureLabelMapping createFeatureLabelMapping();
/**
+ * Returns a new object of class '<em>Ocl Choice Label Mapping</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Ocl Choice Label Mapping</em>'.
+ * @generated
+ */
+ OclChoiceLabelMapping createOclChoiceLabelMapping();
+
+ /**
* Returns a new object of class '<em>Design Label Mapping</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapPackage.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapPackage.java
index e6609bc63..9b3f9d486 100644
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapPackage.java
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/GMFMapPackage.java
@@ -940,6 +940,79 @@ public interface GMFMapPackage extends EPackage {
int FEATURE_LABEL_MAPPING_FEATURE_COUNT = LABEL_MAPPING_FEATURE_COUNT + 7;
/**
+ * The meta object id for the '{@link org.eclipse.gmf.mappings.impl.OclChoiceLabelMappingImpl <em>Ocl Choice Label Mapping</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.gmf.mappings.impl.OclChoiceLabelMappingImpl
+ * @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getOclChoiceLabelMapping()
+ * @generated
+ */
+ int OCL_CHOICE_LABEL_MAPPING = 12;
+
+ /**
+ * The feature id for the '<em><b>Diagram Label</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_LABEL_MAPPING__DIAGRAM_LABEL = LABEL_MAPPING__DIAGRAM_LABEL;
+
+ /**
+ * The feature id for the '<em><b>Read Only</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_LABEL_MAPPING__READ_ONLY = LABEL_MAPPING__READ_ONLY;
+
+ /**
+ * The feature id for the '<em><b>Map Entry</b></em>' container reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_LABEL_MAPPING__MAP_ENTRY = LABEL_MAPPING__MAP_ENTRY;
+
+ /**
+ * The feature id for the '<em><b>Feature</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_LABEL_MAPPING__FEATURE = LABEL_MAPPING_FEATURE_COUNT + 0;
+
+ /**
+ * The feature id for the '<em><b>Items Expression</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION = LABEL_MAPPING_FEATURE_COUNT + 1;
+
+ /**
+ * The feature id for the '<em><b>Show Expression</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION = LABEL_MAPPING_FEATURE_COUNT + 2;
+
+ /**
+ * The number of structural features of the '<em>Ocl Choice Label Mapping</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int OCL_CHOICE_LABEL_MAPPING_FEATURE_COUNT = LABEL_MAPPING_FEATURE_COUNT + 3;
+
+ /**
* The meta object id for the '{@link org.eclipse.gmf.mappings.impl.DesignLabelMappingImpl <em>Design Label Mapping</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -947,7 +1020,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getDesignLabelMapping()
* @generated
*/
- int DESIGN_LABEL_MAPPING = 12;
+ int DESIGN_LABEL_MAPPING = 13;
/**
* The feature id for the '<em><b>Diagram Label</b></em>' reference.
@@ -993,7 +1066,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getExpressionLabelMapping()
* @generated
*/
- int EXPRESSION_LABEL_MAPPING = 13;
+ int EXPRESSION_LABEL_MAPPING = 14;
/**
* The feature id for the '<em><b>Diagram Label</b></em>' reference.
@@ -1066,7 +1139,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getValueExpression()
* @generated
*/
- int VALUE_EXPRESSION = 16;
+ int VALUE_EXPRESSION = 17;
/**
* The feature id for the '<em><b>Body</b></em>' attribute.
@@ -1112,7 +1185,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getConstraint()
* @generated
*/
- int CONSTRAINT = 14;
+ int CONSTRAINT = 15;
/**
* The feature id for the '<em><b>Body</b></em>' attribute.
@@ -1159,7 +1232,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getLinkConstraints()
* @generated
*/
- int LINK_CONSTRAINTS = 15;
+ int LINK_CONSTRAINTS = 16;
/**
* The feature id for the '<em><b>Link Mapping</b></em>' container reference.
@@ -1205,7 +1278,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getElementInitializer()
* @generated
*/
- int ELEMENT_INITIALIZER = 17;
+ int ELEMENT_INITIALIZER = 18;
/**
* The feature id for the '<em><b>Mapping Entry</b></em>' reference.
@@ -1233,7 +1306,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getFeatureSeqInitializer()
* @generated
*/
- int FEATURE_SEQ_INITIALIZER = 18;
+ int FEATURE_SEQ_INITIALIZER = 19;
/**
* The feature id for the '<em><b>Mapping Entry</b></em>' reference.
@@ -1288,7 +1361,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getFeatureInitializer()
* @generated
*/
- int FEATURE_INITIALIZER = 19;
+ int FEATURE_INITIALIZER = 20;
/**
* The feature id for the '<em><b>Feature</b></em>' reference.
@@ -1325,7 +1398,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getFeatureValueSpec()
* @generated
*/
- int FEATURE_VALUE_SPEC = 20;
+ int FEATURE_VALUE_SPEC = 21;
/**
* The feature id for the '<em><b>Feature</b></em>' reference.
@@ -1372,7 +1445,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getReferenceNewElementSpec()
* @generated
*/
- int REFERENCE_NEW_ELEMENT_SPEC = 21;
+ int REFERENCE_NEW_ELEMENT_SPEC = 22;
/**
* The feature id for the '<em><b>Feature</b></em>' reference.
@@ -1418,7 +1491,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getMenuOwner()
* @generated
*/
- int MENU_OWNER = 22;
+ int MENU_OWNER = 23;
/**
* The feature id for the '<em><b>Context Menu</b></em>' reference.
@@ -1446,7 +1519,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getToolOwner()
* @generated
*/
- int TOOL_OWNER = 23;
+ int TOOL_OWNER = 24;
/**
* The feature id for the '<em><b>Tool</b></em>' reference.
@@ -1474,7 +1547,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getAppearanceSteward()
* @generated
*/
- int APPEARANCE_STEWARD = 24;
+ int APPEARANCE_STEWARD = 25;
/**
* The feature id for the '<em><b>Appearance Style</b></em>' reference.
@@ -1502,7 +1575,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getAuditContainer()
* @generated
*/
- int AUDIT_CONTAINER = 25;
+ int AUDIT_CONTAINER = 26;
/**
* The feature id for the '<em><b>Id</b></em>' attribute.
@@ -1575,7 +1648,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getRuleBase()
* @generated
*/
- int RULE_BASE = 26;
+ int RULE_BASE = 27;
/**
* The feature id for the '<em><b>Name</b></em>' attribute.
@@ -1612,7 +1685,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getAuditRule()
* @generated
*/
- int AUDIT_RULE = 27;
+ int AUDIT_RULE = 28;
/**
* The feature id for the '<em><b>Name</b></em>' attribute.
@@ -1712,7 +1785,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getAuditable()
* @generated
*/
- int AUDITABLE = 35;
+ int AUDITABLE = 36;
/**
* The number of structural features of the '<em>Auditable</em>' class.
@@ -1731,7 +1804,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getDomainElementTarget()
* @generated
*/
- int DOMAIN_ELEMENT_TARGET = 28;
+ int DOMAIN_ELEMENT_TARGET = 29;
/**
* The feature id for the '<em><b>Element</b></em>' reference.
@@ -1759,7 +1832,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getDomainAttributeTarget()
* @generated
*/
- int DOMAIN_ATTRIBUTE_TARGET = 29;
+ int DOMAIN_ATTRIBUTE_TARGET = 30;
/**
* The feature id for the '<em><b>Attribute</b></em>' reference.
@@ -1796,7 +1869,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getDiagramElementTarget()
* @generated
*/
- int DIAGRAM_ELEMENT_TARGET = 30;
+ int DIAGRAM_ELEMENT_TARGET = 31;
/**
* The feature id for the '<em><b>Element</b></em>' reference.
@@ -1824,7 +1897,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getNotationElementTarget()
* @generated
*/
- int NOTATION_ELEMENT_TARGET = 31;
+ int NOTATION_ELEMENT_TARGET = 32;
/**
* The feature id for the '<em><b>Element</b></em>' reference.
@@ -1852,7 +1925,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getMetricContainer()
* @generated
*/
- int METRIC_CONTAINER = 32;
+ int METRIC_CONTAINER = 33;
/**
* The feature id for the '<em><b>Metrics</b></em>' containment reference list.
@@ -1880,7 +1953,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getMetricRule()
* @generated
*/
- int METRIC_RULE = 33;
+ int METRIC_RULE = 34;
/**
* The feature id for the '<em><b>Name</b></em>' attribute.
@@ -1971,7 +2044,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getAuditedMetricTarget()
* @generated
*/
- int AUDITED_METRIC_TARGET = 34;
+ int AUDITED_METRIC_TARGET = 35;
/**
* The feature id for the '<em><b>Metric</b></em>' reference.
@@ -1999,7 +2072,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getMeasurable()
* @generated
*/
- int MEASURABLE = 36;
+ int MEASURABLE = 37;
/**
* The number of structural features of the '<em>Measurable</em>' class.
@@ -2018,7 +2091,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getLabelTextAccessMethod()
* @generated
*/
- int LABEL_TEXT_ACCESS_METHOD = 37;
+ int LABEL_TEXT_ACCESS_METHOD = 38;
/**
* The meta object id for the '{@link org.eclipse.gmf.mappings.Severity <em>Severity</em>}' enum.
@@ -2028,7 +2101,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getSeverity()
* @generated
*/
- int SEVERITY = 38;
+ int SEVERITY = 39;
/**
@@ -2039,7 +2112,7 @@ public interface GMFMapPackage extends EPackage {
* @see org.eclipse.gmf.mappings.impl.GMFMapPackageImpl#getLanguage()
* @generated
*/
- int LANGUAGE = 39;
+ int LANGUAGE = 40;
/**
@@ -2582,6 +2655,49 @@ public interface GMFMapPackage extends EPackage {
EAttribute getFeatureLabelMapping_EditMethod();
/**
+ * Returns the meta object for class '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping <em>Ocl Choice Label Mapping</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Ocl Choice Label Mapping</em>'.
+ * @see org.eclipse.gmf.mappings.OclChoiceLabelMapping
+ * @generated
+ */
+ EClass getOclChoiceLabelMapping();
+
+ /**
+ * Returns the meta object for the reference '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getFeature <em>Feature</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference '<em>Feature</em>'.
+ * @see org.eclipse.gmf.mappings.OclChoiceLabelMapping#getFeature()
+ * @see #getOclChoiceLabelMapping()
+ * @generated
+ */
+ EReference getOclChoiceLabelMapping_Feature();
+
+ /**
+ * Returns the meta object for the containment reference '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getItemsExpression <em>Items Expression</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference '<em>Items Expression</em>'.
+ * @see org.eclipse.gmf.mappings.OclChoiceLabelMapping#getItemsExpression()
+ * @see #getOclChoiceLabelMapping()
+ * @generated
+ */
+ EReference getOclChoiceLabelMapping_ItemsExpression();
+
+ /**
+ * Returns the meta object for the containment reference '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getShowExpression <em>Show Expression</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference '<em>Show Expression</em>'.
+ * @see org.eclipse.gmf.mappings.OclChoiceLabelMapping#getShowExpression()
+ * @see #getOclChoiceLabelMapping()
+ * @generated
+ */
+ EReference getOclChoiceLabelMapping_ShowExpression();
+
+ /**
* Returns the meta object for class '{@link org.eclipse.gmf.mappings.DesignLabelMapping <em>Design Label Mapping</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/OclChoiceLabelMapping.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/OclChoiceLabelMapping.java
new file mode 100644
index 000000000..4180804f9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/OclChoiceLabelMapping.java
@@ -0,0 +1,115 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.mappings;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Ocl Choice Label Mapping</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <!-- begin-model-doc -->
+ * Label based on a feature (reference or attribute) from domain model and list of choices
+ * <!-- end-model-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getFeature <em>Feature</em>}</li>
+ * <li>{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getItemsExpression <em>Items Expression</em>}</li>
+ * <li>{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getShowExpression <em>Show Expression</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see org.eclipse.gmf.mappings.GMFMapPackage#getOclChoiceLabelMapping()
+ * @model
+ * @generated
+ */
+public interface OclChoiceLabelMapping extends LabelMapping {
+ /**
+ * Returns the value of the '<em><b>Feature</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Feature</em>' reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Feature</em>' reference.
+ * @see #setFeature(EStructuralFeature)
+ * @see org.eclipse.gmf.mappings.GMFMapPackage#getOclChoiceLabelMapping_Feature()
+ * @model required="true"
+ * annotation="http://www.eclipse.org/gmf/2005/constraints ocl='feature.eContainingClass.isSuperTypeOf(mapEntry.domainMetaElement)' description='Label reference must be available in \'Domain Element\' EClass of the labeled mapping entry'"
+ * annotation="http://www.eclipse.org/gmf/2005/constraints ocl='feature.oclIsKindOf(ecore::EReference) implies (not(feature.oclAsType(ecore::EReference).containment) and (feature.oclAsType(ecore::EReference).upperBound = 1))' description='Reference feature should not be containment and don\'t be multiple'"
+ * annotation="http://www.eclipse.org/gmf/2005/constraints ocl='feature.oclIsKindOf(ecore::EAttribute) implies (itemsExpression <> null)' description='Items expression should be set if feature is an EAttribute'"
+ * @generated
+ */
+ EStructuralFeature getFeature();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getFeature <em>Feature</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Feature</em>' reference.
+ * @see #getFeature()
+ * @generated
+ */
+ void setFeature(EStructuralFeature value);
+
+ /**
+ * Returns the value of the '<em><b>Items Expression</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Items Expression</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Items Expression</em>' containment reference.
+ * @see #setItemsExpression(ValueExpression)
+ * @see org.eclipse.gmf.mappings.GMFMapPackage#getOclChoiceLabelMapping_ItemsExpression()
+ * @model containment="true"
+ * @generated
+ */
+ ValueExpression getItemsExpression();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getItemsExpression <em>Items Expression</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Items Expression</em>' containment reference.
+ * @see #getItemsExpression()
+ * @generated
+ */
+ void setItemsExpression(ValueExpression value);
+
+ /**
+ * Returns the value of the '<em><b>Show Expression</b></em>' containment reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Show Expression</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Show Expression</em>' containment reference.
+ * @see #setShowExpression(ValueExpression)
+ * @see org.eclipse.gmf.mappings.GMFMapPackage#getOclChoiceLabelMapping_ShowExpression()
+ * @model containment="true"
+ * @generated
+ */
+ ValueExpression getShowExpression();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping#getShowExpression <em>Show Expression</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Show Expression</em>' containment reference.
+ * @see #getShowExpression()
+ * @generated
+ */
+ void setShowExpression(ValueExpression value);
+
+} // OclChoiceLabelMapping
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapFactoryImpl.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapFactoryImpl.java
index 69d571241..0cc77f0fe 100644
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapFactoryImpl.java
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapFactoryImpl.java
@@ -86,6 +86,7 @@ public class GMFMapFactoryImpl extends EFactoryImpl implements GMFMapFactory {
case GMFMapPackage.CANVAS_MAPPING: return createCanvasMapping();
case GMFMapPackage.LABEL_MAPPING: return createLabelMapping();
case GMFMapPackage.FEATURE_LABEL_MAPPING: return createFeatureLabelMapping();
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING: return createOclChoiceLabelMapping();
case GMFMapPackage.DESIGN_LABEL_MAPPING: return createDesignLabelMapping();
case GMFMapPackage.EXPRESSION_LABEL_MAPPING: return createExpressionLabelMapping();
case GMFMapPackage.CONSTRAINT: return createConstraint();
@@ -211,6 +212,16 @@ public class GMFMapFactoryImpl extends EFactoryImpl implements GMFMapFactory {
* <!-- end-user-doc -->
* @generated
*/
+ public OclChoiceLabelMapping createOclChoiceLabelMapping() {
+ OclChoiceLabelMappingImpl oclChoiceLabelMapping = new OclChoiceLabelMappingImpl();
+ return oclChoiceLabelMapping;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public DesignLabelMapping createDesignLabelMapping() {
DesignLabelMappingImpl designLabelMapping = new DesignLabelMappingImpl();
return designLabelMapping;
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java
index d3518fd14..7df1197b1 100644
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/GMFMapPackageImpl.java
@@ -51,13 +51,13 @@ import org.eclipse.gmf.mappings.NeedsContainment;
import org.eclipse.gmf.mappings.NodeMapping;
import org.eclipse.gmf.mappings.NodeReference;
import org.eclipse.gmf.mappings.NotationElementTarget;
+import org.eclipse.gmf.mappings.OclChoiceLabelMapping;
import org.eclipse.gmf.mappings.ReferenceNewElementSpec;
import org.eclipse.gmf.mappings.RuleBase;
import org.eclipse.gmf.mappings.Severity;
import org.eclipse.gmf.mappings.ToolOwner;
import org.eclipse.gmf.mappings.TopNodeReference;
import org.eclipse.gmf.mappings.ValueExpression;
-import org.eclipse.gmf.mappings.*;
import org.eclipse.gmf.tooldef.GMFToolPackage;
import org.eclipse.gmf.validate.GMFValidator;
@@ -150,6 +150,13 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
* <!-- end-user-doc -->
* @generated
*/
+ private EClass oclChoiceLabelMappingEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
private EClass designLabelMappingEClass = null;
/**
@@ -875,6 +882,42 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
* <!-- end-user-doc -->
* @generated
*/
+ public EClass getOclChoiceLabelMapping() {
+ return oclChoiceLabelMappingEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getOclChoiceLabelMapping_Feature() {
+ return (EReference)oclChoiceLabelMappingEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getOclChoiceLabelMapping_ItemsExpression() {
+ return (EReference)oclChoiceLabelMappingEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getOclChoiceLabelMapping_ShowExpression() {
+ return (EReference)oclChoiceLabelMappingEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getDesignLabelMapping() {
return designLabelMappingEClass;
}
@@ -1714,6 +1757,11 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
createEAttribute(featureLabelMappingEClass, FEATURE_LABEL_MAPPING__VIEW_METHOD);
createEAttribute(featureLabelMappingEClass, FEATURE_LABEL_MAPPING__EDIT_METHOD);
+ oclChoiceLabelMappingEClass = createEClass(OCL_CHOICE_LABEL_MAPPING);
+ createEReference(oclChoiceLabelMappingEClass, OCL_CHOICE_LABEL_MAPPING__FEATURE);
+ createEReference(oclChoiceLabelMappingEClass, OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION);
+ createEReference(oclChoiceLabelMappingEClass, OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION);
+
designLabelMappingEClass = createEClass(DESIGN_LABEL_MAPPING);
expressionLabelMappingEClass = createEClass(EXPRESSION_LABEL_MAPPING);
@@ -1863,6 +1911,7 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
linkMappingEClass.getESuperTypes().add(this.getToolOwner());
linkMappingEClass.getESuperTypes().add(this.getAppearanceSteward());
featureLabelMappingEClass.getESuperTypes().add(this.getLabelMapping());
+ oclChoiceLabelMappingEClass.getESuperTypes().add(this.getLabelMapping());
designLabelMappingEClass.getESuperTypes().add(this.getLabelMapping());
expressionLabelMappingEClass.getESuperTypes().add(this.getLabelMapping());
constraintEClass.getESuperTypes().add(this.getValueExpression());
@@ -1952,6 +2001,11 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
initEAttribute(getFeatureLabelMapping_ViewMethod(), this.getLabelTextAccessMethod(), "viewMethod", null, 0, 1, FeatureLabelMapping.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getFeatureLabelMapping_EditMethod(), this.getLabelTextAccessMethod(), "editMethod", null, 0, 1, FeatureLabelMapping.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEClass(oclChoiceLabelMappingEClass, OclChoiceLabelMapping.class, "OclChoiceLabelMapping", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getOclChoiceLabelMapping_Feature(), ecorePackage.getEStructuralFeature(), null, "feature", null, 1, 1, OclChoiceLabelMapping.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getOclChoiceLabelMapping_ItemsExpression(), this.getValueExpression(), null, "itemsExpression", null, 0, 1, OclChoiceLabelMapping.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getOclChoiceLabelMapping_ShowExpression(), this.getValueExpression(), null, "showExpression", null, 0, 1, OclChoiceLabelMapping.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
initEClass(designLabelMappingEClass, DesignLabelMapping.class, "DesignLabelMapping", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEClass(expressionLabelMappingEClass, ExpressionLabelMapping.class, "ExpressionLabelMapping", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
@@ -2095,7 +2149,7 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
new String[] {
"constraints", "http://www.eclipse.org/gmf/2005/constraints",
"constraintsMeta", "http://www.eclipse.org/gmf/2005/constraints/meta"
- });
+ });
}
/**
@@ -2112,7 +2166,7 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
new String[] {
"def", "context",
"ocl", "self.getDomainContext()"
- });
+ });
addAnnotation
(constraintEClass,
source,
@@ -2385,7 +2439,28 @@ public class GMFMapPackageImpl extends EPackageImpl implements GMFMapPackage {
new String[] {
"ocl", "editableFeatures->forAll(f | f.eContainingClass.isSuperTypeOf(mapEntry.domainMetaElement))",
"description", "Label attributes must be available in \'Domain Element\' EClass of the labeled mapping entry"
- });
+ });
+ addAnnotation
+ (getOclChoiceLabelMapping_Feature(),
+ source,
+ new String[] {
+ "ocl", "feature.eContainingClass.isSuperTypeOf(mapEntry.domainMetaElement)",
+ "description", "Label reference must be available in \'Domain Element\' EClass of the labeled mapping entry"
+ });
+ addAnnotation
+ (getOclChoiceLabelMapping_Feature(),
+ source,
+ new String[] {
+ "ocl", "feature.oclIsKindOf(ecore::EReference) implies (not(feature.oclAsType(ecore::EReference).containment) and (feature.oclAsType(ecore::EReference).upperBound = 1))",
+ "description", "Reference feature should not be containment and don\'t be multiple"
+ });
+ addAnnotation
+ (getOclChoiceLabelMapping_Feature(),
+ source,
+ new String[] {
+ "ocl", "feature.oclIsKindOf(ecore::EAttribute) implies (itemsExpression <> null)",
+ "description", "Items expression should be set if feature is an EAttribute"
+ });
addAnnotation
(linkConstraintsEClass,
source,
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/OclChoiceLabelMappingImpl.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/OclChoiceLabelMappingImpl.java
new file mode 100644
index 000000000..5c406caea
--- /dev/null
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/impl/OclChoiceLabelMappingImpl.java
@@ -0,0 +1,306 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.gmf.mappings.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.common.notify.NotificationChain;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+
+import org.eclipse.gmf.mappings.GMFMapPackage;
+import org.eclipse.gmf.mappings.OclChoiceLabelMapping;
+import org.eclipse.gmf.mappings.ValueExpression;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Ocl Choice Label Mapping</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.eclipse.gmf.mappings.impl.OclChoiceLabelMappingImpl#getFeature <em>Feature</em>}</li>
+ * <li>{@link org.eclipse.gmf.mappings.impl.OclChoiceLabelMappingImpl#getItemsExpression <em>Items Expression</em>}</li>
+ * <li>{@link org.eclipse.gmf.mappings.impl.OclChoiceLabelMappingImpl#getShowExpression <em>Show Expression</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class OclChoiceLabelMappingImpl extends LabelMappingImpl implements OclChoiceLabelMapping {
+ /**
+ * The cached value of the '{@link #getFeature() <em>Feature</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getFeature()
+ * @generated
+ * @ordered
+ */
+ protected EStructuralFeature feature;
+
+ /**
+ * The cached value of the '{@link #getItemsExpression() <em>Items Expression</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getItemsExpression()
+ * @generated
+ * @ordered
+ */
+ protected ValueExpression itemsExpression;
+
+ /**
+ * The cached value of the '{@link #getShowExpression() <em>Show Expression</em>}' containment reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getShowExpression()
+ * @generated
+ * @ordered
+ */
+ protected ValueExpression showExpression;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected OclChoiceLabelMappingImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return GMFMapPackage.eINSTANCE.getOclChoiceLabelMapping();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EStructuralFeature getFeature() {
+ if (feature != null && feature.eIsProxy()) {
+ InternalEObject oldFeature = (InternalEObject)feature;
+ feature = (EStructuralFeature)eResolveProxy(oldFeature);
+ if (feature != oldFeature) {
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__FEATURE, oldFeature, feature));
+ }
+ }
+ return feature;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EStructuralFeature basicGetFeature() {
+ return feature;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setFeature(EStructuralFeature newFeature) {
+ EStructuralFeature oldFeature = feature;
+ feature = newFeature;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__FEATURE, oldFeature, feature));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ValueExpression getItemsExpression() {
+ return itemsExpression;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetItemsExpression(ValueExpression newItemsExpression, NotificationChain msgs) {
+ ValueExpression oldItemsExpression = itemsExpression;
+ itemsExpression = newItemsExpression;
+ if (eNotificationRequired()) {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION, oldItemsExpression, newItemsExpression);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setItemsExpression(ValueExpression newItemsExpression) {
+ if (newItemsExpression != itemsExpression) {
+ NotificationChain msgs = null;
+ if (itemsExpression != null)
+ msgs = ((InternalEObject)itemsExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION, null, msgs);
+ if (newItemsExpression != null)
+ msgs = ((InternalEObject)newItemsExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION, null, msgs);
+ msgs = basicSetItemsExpression(newItemsExpression, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION, newItemsExpression, newItemsExpression));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ValueExpression getShowExpression() {
+ return showExpression;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetShowExpression(ValueExpression newShowExpression, NotificationChain msgs) {
+ ValueExpression oldShowExpression = showExpression;
+ showExpression = newShowExpression;
+ if (eNotificationRequired()) {
+ ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION, oldShowExpression, newShowExpression);
+ if (msgs == null) msgs = notification; else msgs.add(notification);
+ }
+ return msgs;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setShowExpression(ValueExpression newShowExpression) {
+ if (newShowExpression != showExpression) {
+ NotificationChain msgs = null;
+ if (showExpression != null)
+ msgs = ((InternalEObject)showExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION, null, msgs);
+ if (newShowExpression != null)
+ msgs = ((InternalEObject)newShowExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION, null, msgs);
+ msgs = basicSetShowExpression(newShowExpression, msgs);
+ if (msgs != null) msgs.dispatch();
+ }
+ else if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION, newShowExpression, newShowExpression));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION:
+ return basicSetItemsExpression(null, msgs);
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION:
+ return basicSetShowExpression(null, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__FEATURE:
+ if (resolve) return getFeature();
+ return basicGetFeature();
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION:
+ return getItemsExpression();
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION:
+ return getShowExpression();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__FEATURE:
+ setFeature((EStructuralFeature)newValue);
+ return;
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION:
+ setItemsExpression((ValueExpression)newValue);
+ return;
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION:
+ setShowExpression((ValueExpression)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__FEATURE:
+ setFeature((EStructuralFeature)null);
+ return;
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION:
+ setItemsExpression((ValueExpression)null);
+ return;
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION:
+ setShowExpression((ValueExpression)null);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__FEATURE:
+ return feature != null;
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__ITEMS_EXPRESSION:
+ return itemsExpression != null;
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING__SHOW_EXPRESSION:
+ return showExpression != null;
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //OclChoiceLabelMappingImpl
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapAdapterFactory.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapAdapterFactory.java
index e82fa5f61..7280d0122 100644
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapAdapterFactory.java
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapAdapterFactory.java
@@ -141,6 +141,10 @@ public class GMFMapAdapterFactory extends AdapterFactoryImpl {
return createFeatureLabelMappingAdapter();
}
@Override
+ public Adapter caseOclChoiceLabelMapping(OclChoiceLabelMapping object) {
+ return createOclChoiceLabelMappingAdapter();
+ }
+ @Override
public Adapter caseDesignLabelMapping(DesignLabelMapping object) {
return createDesignLabelMappingAdapter();
}
@@ -415,6 +419,20 @@ public class GMFMapAdapterFactory extends AdapterFactoryImpl {
}
/**
+ * Creates a new adapter for an object of class '{@link org.eclipse.gmf.mappings.OclChoiceLabelMapping <em>Ocl Choice Label Mapping</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.gmf.mappings.OclChoiceLabelMapping
+ * @generated
+ */
+ public Adapter createOclChoiceLabelMappingAdapter() {
+ return null;
+ }
+
+ /**
* Creates a new adapter for an object of class '{@link org.eclipse.gmf.mappings.DesignLabelMapping <em>Design Label Mapping</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
diff --git a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapSwitch.java b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapSwitch.java
index f03a4c242..07521d21c 100644
--- a/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapSwitch.java
+++ b/plugins/org.eclipse.gmf.map/src/org/eclipse/gmf/mappings/util/GMFMapSwitch.java
@@ -182,6 +182,13 @@ public class GMFMapSwitch<T> extends Switch<T> {
if (result == null) result = defaultCase(theEObject);
return result;
}
+ case GMFMapPackage.OCL_CHOICE_LABEL_MAPPING: {
+ OclChoiceLabelMapping oclChoiceLabelMapping = (OclChoiceLabelMapping)theEObject;
+ T result = caseOclChoiceLabelMapping(oclChoiceLabelMapping);
+ if (result == null) result = caseLabelMapping(oclChoiceLabelMapping);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
case GMFMapPackage.DESIGN_LABEL_MAPPING: {
DesignLabelMapping designLabelMapping = (DesignLabelMapping)theEObject;
T result = caseDesignLabelMapping(designLabelMapping);
@@ -518,6 +525,21 @@ public class GMFMapSwitch<T> extends Switch<T> {
}
/**
+ * Returns the result of interpreting the object as an instance of '<em>Ocl Choice Label Mapping</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Ocl Choice Label Mapping</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseOclChoiceLabelMapping(OclChoiceLabelMapping object) {
+ return null;
+ }
+
+ /**
* Returns the result of interpreting the object as an instance of '<em>Design Label Mapping</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/META-INF/MANIFEST.MF b/plugins/org.eclipse.gmf.tooling.runtime/META-INF/MANIFEST.MF
index 0aa38bc51..6153b3ce9 100644
--- a/plugins/org.eclipse.gmf.tooling.runtime/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.gmf.tooling.runtime/META-INF/MANIFEST.MF
@@ -12,8 +12,16 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.gef;visibility:=reexport,
org.eclipse.gmf.runtime.emf.commands.core,
org.eclipse.gmf.runtime.common.ui.services,
- org.eclipse.gmf.runtime.emf.type.core
+ org.eclipse.gmf.runtime.emf.type.core,
+ org.eclipse.gmf.runtime.diagram.core,
+ org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.ocl,
+ org.eclipse.ocl.ecore
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Activator: org.eclipse.gmf.tooling.runtime.GMFToolingRuntimePlugin
+Export-Package: org.eclipse.gmf.tooling.runtime,
+ org.eclipse.gmf.tooling.runtime.directedit,
+ org.eclipse.gmf.tooling.runtime.ocl.tracker,
+ org.eclipse.gmf.tooling.runtime.parsers
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/messages.properties b/plugins/org.eclipse.gmf.tooling.runtime/messages.properties
index 9920f8697..4f2f1324a 100644
--- a/plugins/org.eclipse.gmf.tooling.runtime/messages.properties
+++ b/plugins/org.eclipse.gmf.tooling.runtime/messages.properties
@@ -1,3 +1,3 @@
-AbstractParser_UnexpectedValueType=Value of type {0} is expected
-AbstractParser_WrongStringConversion=String value does not convert to {0} value
-AbstractParser_UnknownLiteral=Unknown literal: {0}
+AbstractAttributeParser_UnexpectedValueType=Value of type {0} is expected
+AbstractAttributeParser_WrongStringConversion=String value does not convert to {0} value
+AbstractAttributeParser_UnknownLiteral=Unknown literal: {0}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/GMFToolingRuntimePlugin.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/GMFToolingRuntimePlugin.java
index 2dd148761..acc5a2b78 100644
--- a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/GMFToolingRuntimePlugin.java
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/GMFToolingRuntimePlugin.java
@@ -1,5 +1,7 @@
package org.eclipse.gmf.tooling.runtime;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl.ActiveOclTrackerFactory;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -23,4 +25,26 @@ public class GMFToolingRuntimePlugin extends AbstractUIPlugin {
return ourInstance;
}
+ /**
+ * This is the main intended way to access the {@link OclTrackerFactory}.
+ * This method will return the suited implementation based on the available plugins.
+ * Caller should not make any assumptions against the return implementation type.
+ */
+ public OclTrackerFactory getOclTrackerFactory() {
+ return new ActiveOclTrackerFactory();
+ }
+
+ /**
+ * This is the helper method allowing caller to access the specific {@link OclTrackerFactory}
+ * implementation without adding an explicit dependency to the containing plugin.
+ * <p>
+ * This method will try to return the preferred implementation based on the available plugins,
+ * but will roll back to default implementation if preferred one is not available.
+ * Caller still is not recommended to make any assumptions about the returned implementation type.
+ */
+ public OclTrackerFactory getOclTrackerFactory(OclTrackerFactory.Type type) {
+ //XXX: without IA included to Eclipse distribution, this method always return the default GMFT implementation.
+ return getOclTrackerFactory();
+ }
+
}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/Messages.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/Messages.java
index 06b8b695e..d5f38ad9a 100644
--- a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/Messages.java
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/Messages.java
@@ -11,9 +11,9 @@ public class Messages extends NLS {
private Messages() {
}
- public static String AbstractParser_UnexpectedValueType;
+ public static String AbstractAttributeParser_UnexpectedValueType;
- public static String AbstractParser_WrongStringConversion;
+ public static String AbstractAttributeParser_WrongStringConversion;
- public static String AbstractParser_UnknownLiteral;
+ public static String AbstractAttributeParser_UnknownLiteral;
}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorEx.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorEx.java
new file mode 100644
index 000000000..a738c687b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorEx.java
@@ -0,0 +1,26 @@
+/******************************************************************************
+ * Copyright (c) 2012 Montages.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Svyatoslav Kovalsky (Montages) - initial API and implementation
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+/**
+ * @since 1.6
+ */
+public interface CellEditorEx {
+
+ public void setValueAndProcessEditOccured(Object value);
+
+ public boolean hasValueChanged();
+
+ public boolean isDeactivationLocked();
+
+ public void setDeactivationLock(boolean deactivationLock);
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorExDelegate.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorExDelegate.java
new file mode 100644
index 000000000..d8c9cb0b5
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/CellEditorExDelegate.java
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Svyatoslav Kovalsky (Montages) - contribution for bugzilla 371888
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+import org.eclipse.jface.viewers.CellEditor;
+
+/**
+ * @since 1.6
+ */
+/*public */class CellEditorExDelegate {
+
+ private final CellEditor myOwner;
+
+ private Object originalValue;
+
+ private boolean deactivationLock = false;
+
+ public CellEditorExDelegate(CellEditor owner) {
+ myOwner = owner;
+ }
+
+ public void setOriginalValue(Object value) {
+ if (originalValue == null)
+ originalValue = value;
+ }
+
+ /**
+ * @return boolean value specifying whether or not the value has been
+ * changed
+ */
+ public boolean hasValueChanged() {
+ if (myOwner.getValue() == null)
+ return originalValue != null;
+ return !myOwner.getValue().equals(originalValue);
+ }
+
+ /**
+ * Returns true if deactivation has been locked
+ *
+ * @return
+ */
+ public boolean isDeactivationLocked() {
+ return deactivationLock;
+ }
+
+ /**
+ * Sets deactivation lock so that the cell editor does not perform
+ * deactivate
+ *
+ * @param deactivationLock
+ */
+ public void setDeactivationLock(boolean deactivationLock) {
+ this.deactivationLock = deactivationLock;
+ }
+
+ /*
+ * unlocks deactivation if it has been locked
+ */
+ public boolean unlockDeactivation() {
+ if (isDeactivationLocked()) {
+ setDeactivationLock(false);
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboCellEditorEx.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboCellEditorEx.java
new file mode 100644
index 000000000..27eb22468
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboCellEditorEx.java
@@ -0,0 +1,129 @@
+/******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Svyatoslav Kovalsky (Montages) - initial API and implementation
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 1.5
+ */
+/* public */class ComboCellEditorEx extends ComboBoxCellEditor implements CellEditorEx {
+
+ private static final int ourStyle = SWT.READ_ONLY;
+
+ private CellEditorExDelegate myExDelegate;
+
+ public ComboCellEditorEx() {
+ setStyle(ourStyle);
+ }
+
+ /**
+ * @param parent
+ * the parent control
+ * @param items
+ * the list of strings for the combo box
+ */
+ public ComboCellEditorEx(Composite parent, String[] items) {
+ super(parent, items, ourStyle);
+ }
+
+ private CellEditorExDelegate getExDelegate() {
+ if (myExDelegate == null) {
+ myExDelegate = new CellEditorExDelegate(this);
+ }
+ return myExDelegate;
+ }
+
+ /**
+ * This will be used when an edit has occurred by a ModifyEvent has been
+ * been send. Will call #setValue(Object) but will also call
+ * editOccured(null) to make sure that the dirty flag is set probably and
+ * that any listeners are informed about the changed.
+ *
+ * @param value
+ * Value to set the cell editor to.
+ *
+ * Note: This happens address defect RATLC00522324. For our
+ * topgraphical edit parts we delagate the direct edit request to
+ * a primary edit part and set focus on that. The issue is that
+ * if the user has typed in an initial character when setting
+ * focus to the edit part, which typically is a
+ * TextCompartmentEditPart then setting that intial value does
+ * not fire the necessary change events that need to occur in
+ * order for that value to be recongnized. If you don't use this
+ * method then the result is that if you just type in the initial
+ * character and that is it then the text compartment loses focus
+ * then the value will not be saved. This is because setting the
+ * value of the cell doesn't think its value has changed since
+ * the first character is not recongized as a change.
+ */
+ public void setValueAndProcessEditOccured(Object value) {
+ setValue(value);
+ // assume all values are valid for now
+ valueChanged(true, true);
+ }
+
+ @Override
+ protected void doSetValue(Object value) {
+ getExDelegate().setOriginalValue(value);
+ super.doSetValue(Arrays.asList(getItems()).indexOf(value));
+ }
+
+ @Override
+ protected Object doGetValue() {
+ Integer itemIndex = (Integer) super.doGetValue();
+ return itemIndex == -1 ? null : getItems()[itemIndex];
+ }
+
+ /**
+ * @return boolean value specifying whether or not the value has been
+ * changed
+ */
+ public boolean hasValueChanged() {
+ return getExDelegate().hasValueChanged();
+ }
+
+ /*
+ * Runs super deactivate unless it has been locked and otherwise unlocks
+ * deactivation
+ *
+ * @see org.eclipse.jface.viewers.CellEditor#deactivate()
+ */
+ public void deactivate() {
+ if (!getExDelegate().unlockDeactivation()) {
+ super.deactivate();
+ }
+ }
+
+ /**
+ * Returns true if deactivation has been locked
+ *
+ * @return
+ */
+ public boolean isDeactivationLocked() {
+ return getExDelegate().isDeactivationLocked();
+ }
+
+ /**
+ * Sets deactivation lock so that the cell editor does not perform
+ * deactivate
+ *
+ * @param deactivationLock
+ */
+ public void setDeactivationLock(boolean deactivationLock) {
+ getExDelegate().setDeactivationLock(deactivationLock);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboDirectEditManager.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboDirectEditManager.java
new file mode 100644
index 000000000..631b91d00
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/ComboDirectEditManager.java
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * Copyright (c) 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Svyatoslav Kovalsky (Montages) - initial API and implementation
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @since 1.6
+ */
+public class ComboDirectEditManager extends DirectEditManagerBase {
+
+ /**
+ * constructor
+ *
+ * @param source
+ * <code>GraphicalEditPart</code> to support direct edit of. The
+ * figure of the <code>source</code> edit part must be of type
+ * <code>WrapLabel</code>.
+ */
+ public ComboDirectEditManager(ITextAwareEditPart source) {
+ super(source);
+ }
+
+ /**
+ * @param source
+ * @param editorType
+ * @param locator
+ */
+ public ComboDirectEditManager(GraphicalEditPart source, Class editorType, CellEditorLocator locator) {
+ super(source, editorType, locator);
+ }
+
+ protected CellEditor doCreateCellEditorOn(Composite composite) {
+ ITextAwareEditPart textEditPart = (ITextAwareEditPart) getEditPart();
+ IParser parser = textEditPart.getParser();
+ IChoiceParser choiceParser;
+ if (parser instanceof IChoiceParser) {
+ choiceParser = (IChoiceParser) parser;
+ } else {
+ throw new RuntimeException("IChoiceParser is expected but " + parser //$NON-NLS-1$
+ + " found for EditPart: " + getEditPart() //$NON-NLS-1$
+ + " with model: " + getEditPart().getModel()); //$NON-NLS-1$
+ }
+
+ if (getEditPart() instanceof IGraphicalEditPart) {
+ EObject parserElement = ((IGraphicalEditPart) getEditPart()).resolveSemanticElement();
+ List<String> editChoices = choiceParser.getEditChoices(new EObjectAdapter(parserElement));
+ return new ComboCellEditorEx(composite, editChoices.toArray(new String[editChoices.size()]));
+ } else {
+ throw new RuntimeException("IGraphicalEditPart is expected but " + getEditPart() + " found "); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ @Override
+ protected void createContentAssistant(Control control, Color proposalPopupForegroundColor, Color proposalPopupBackgroundColor, IContentAssistProcessor processor) {
+ // There is no sense in content assistant for Combo manager, since both provide list of strings to choose from
+ }
+
+ public interface IChoiceParser extends IParser {
+
+ public List<String> getEditChoices(IAdaptable element);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/DirectEditManagerBase.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/DirectEditManagerBase.java
new file mode 100644
index 000000000..849972f17
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/DirectEditManagerBase.java
@@ -0,0 +1,565 @@
+/******************************************************************************
+ * Copyright (c) 2002, 2010, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Dmitry Stadnik (Borland) - contribution for bugzilla 135694
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.draw2d.AncestorListener;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.TextUtilities;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.runtime.common.core.util.Log;
+import org.eclipse.gmf.runtime.common.core.util.Trace;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions;
+import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin;
+import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes;
+import org.eclipse.gmf.runtime.diagram.ui.label.ILabelDelegate;
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
+import org.eclipse.jface.resource.DeviceResourceException;
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Scrollable;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+
+/**
+ * @author melaasar
+ * @since 1.6
+ */
+public abstract class DirectEditManagerBase extends DirectEditManager {
+
+ /**
+ * content assist background color
+ */
+ private Color proposalPopupBackgroundColor = null;
+
+ /**
+ * content assist foreground color
+ */
+ private Color proposalPopupForegroundColor = null;
+
+ private boolean committed = false;
+
+ /**
+ * flag used to avoid unhooking listeners twice if the UI thread is blocked
+ */
+ private boolean listenersAttached = true;
+
+ /** String buffer to hold initial characters * */
+ private StringBuffer initialString = new StringBuffer();
+
+ /**
+ * Cache the font descriptor when a font is created so that it can be
+ * disposed later.
+ */
+ private List cachedFontDescriptors = new ArrayList();
+
+ private Font zoomLevelFont = null;
+
+ /**
+ * The superclass only relocates the cell editor when the location of the
+ * editpart's figure moves, but we need to also relocate the cell editor
+ * when the text figure's location changes.
+ */
+ private AncestorListener textFigureListener;
+
+ /**
+ * Cache locally so we can check if the user specified an editorType.
+ */
+ private Class editorType;
+
+ public DirectEditManagerBase(ITextAwareEditPart source) {
+ this(source, null, getCellEditorLocator(source));
+ }
+
+ public DirectEditManagerBase(GraphicalEditPart source, Class editorType, CellEditorLocator locator) {
+ super(source, editorType, locator);
+ this.editorType = editorType;
+ }
+
+ /**
+ * This method is overridden so that the editor class can have a style as
+ * the style needs to be passed into the editor class when it is created. It
+ * will default to the super behavior if an <code>editorType</code> was
+ * passed into the constructor.
+ *
+ * @since 2.1
+ */
+ protected CellEditor createCellEditorOn(Composite composite) {
+ // if the client has overridden this class and provided their own editor
+ // type, then we should use that
+ if (editorType != null) {
+ return super.createCellEditorOn(composite);
+ }
+
+ return doCreateCellEditorOn(composite);
+ }
+
+ /**
+ * @param source
+ * the <code>ITextAwareEditPart</code> to determine the cell
+ * editor for
+ * @return the <code>CellEditorLocator</code> that is appropriate for the
+ * source <code>EditPart</code>
+ */
+ public static CellEditorLocator getCellEditorLocator(final ITextAwareEditPart source) {
+
+ final ILabelDelegate label = (ILabelDelegate) source.getAdapter(ILabelDelegate.class);
+ if (label != null) {
+ return new CellEditorLocator() {
+
+ public void relocate(CellEditor celleditor) {
+ Scrollable control = (Scrollable) celleditor.getControl();
+
+ Rectangle rect = label.getTextBounds().getCopy();
+ if (label.getText().length() <= 0) {
+ // if there is no text, let's assume a default size
+ // of one character because it looks silly when the cell
+ // editor is tiny.
+ rect.setSize(TextUtilities.INSTANCE.getTextExtents("a", control.getFont())); //$NON-NLS-1$
+
+ if (label.isTextWrapOn()) {
+ // adjust the location of the cell editor based on text
+ // justification (i.e. where the cursor will be
+ if (label.getTextJustification() == PositionConstants.RIGHT) {
+ rect.translate(-rect.width, 0);
+ } else if (label.getTextJustification() == PositionConstants.CENTER) {
+ rect.translate(-rect.width / 2, 0);
+ }
+ }
+ }
+
+ if (!control.getFont().isDisposed()) {
+ // Font may be disposed if the locator is called while
+ // this manager is being brought down in which case the
+ // calls below that use the font will result in an
+ // exception.
+ if (label.isTextWrapOn()) {
+ // When zoomed in, the height of this rectangle is not
+ // sufficient because the text is shifted downwards a
+ // little bit. Add some to the height to compensate for
+ // this. I'm not sure why this is happening, but I can
+ // see the text shifting down even in a label on a GEF
+ // logic diagram when zoomed into 400%.
+ int charHeight = FigureUtilities.getFontMetrics(control.getFont()).getHeight();
+ rect.resize(0, charHeight / 2);
+ } else {
+
+ rect.setSize(new Dimension(control.computeSize(SWT.DEFAULT, SWT.DEFAULT)));
+
+ // If SWT.WRAP is not passed in as a style of the
+ // TextCellEditor, then for some reason the first
+ // character disappears upon entering the second
+ // character. This should be investigated and an
+ // SWT bug logged.
+ int avr = FigureUtilities.getFontMetrics(control.getFont()).getAverageCharWidth();
+ rect.setSize(new Dimension(control.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
+ }
+ }
+
+ org.eclipse.swt.graphics.Rectangle newRect = control.computeTrim(rect.x, rect.y, rect.width, rect.height);
+ if (!newRect.equals(control.getBounds())) {
+ control.setBounds(newRect.x, newRect.y, newRect.width, newRect.height);
+ }
+ }
+ };
+ }
+
+ // return a default figure locator
+ return new CellEditorLocator() {
+
+ public void relocate(CellEditor celleditor) {
+ Control control = celleditor.getControl();
+ Rectangle rect = source.getFigure().getBounds().getCopy();
+ source.getFigure().translateToAbsolute(rect);
+ if (!rect.equals(new Rectangle(control.getBounds()))) {
+ control.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ };
+ }
+
+ /**
+ * Given a label figure object, this will calculate the correct Font needed
+ * to display into screen coordinates, taking into account the current
+ * mapmode. This will typically be used by direct edit cell editors that
+ * need to display independent of the zoom or any coordinate mapping that is
+ * taking place on the drawing surface.
+ *
+ * @param label
+ * the label to use for the font calculation
+ * @return the <code>Font</code> that is scaled to the screen coordinates.
+ * Note: the returned <code>Font</code> should not be disposed since
+ * it is cached by a common resource manager.
+ */
+ protected Font getScaledFont(IFigure label) {
+ Font scaledFont = label.getFont();
+ FontData data = scaledFont.getFontData()[0];
+ Dimension fontSize = new Dimension(0, MapModeUtil.getMapMode(label).DPtoLP(data.getHeight()));
+ label.translateToAbsolute(fontSize);
+
+ if (Math.abs(data.getHeight() - fontSize.height) < 2)
+ fontSize.height = data.getHeight();
+
+ try {
+ FontDescriptor fontDescriptor = FontDescriptor.createFrom(data);
+ cachedFontDescriptors.add(fontDescriptor);
+ return getResourceManager().createFont(fontDescriptor);
+ } catch (DeviceResourceException e) {
+ Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getScaledFont", e); //$NON-NLS-1$
+ Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getScaledFont", e); //$NON-NLS-1$
+ }
+ return JFaceResources.getDefaultFont();
+ }
+
+ protected void initCellEditor() {
+ committed = false;
+
+ // Get the Text Compartments Edit Part
+ ITextAwareEditPart textEP = (ITextAwareEditPart) getEditPart();
+
+ setEditText(textEP.getEditText());
+
+ IFigure label = textEP.getFigure();
+ Assert.isNotNull(label);
+ Control control = getCellEditor().getControl();
+ // scale the font accordingly to the zoom level
+ control.setFont(getScaledFont(label));
+
+ // register a validator on the cell editor
+ getCellEditor().setValidator(textEP.getEditTextValidator());
+
+ if (textEP.getParser() != null) {
+ IContentAssistProcessor processor = textEP.getCompletionProcessor();
+ if (processor != null) {
+ // register content assist
+ proposalPopupBackgroundColor = new Color(getCellEditor().getControl().getShell().getDisplay(), new RGB(254, 241, 233));
+ proposalPopupForegroundColor = new Color(getCellEditor().getControl().getShell().getDisplay(), new RGB(0, 0, 0));
+
+ createContentAssistant(control, proposalPopupForegroundColor, proposalPopupBackgroundColor, processor);
+ }
+ }
+ }
+
+ /**
+ * @see org.eclipse.gef.tools.DirectEditManager#commit()
+ */
+ protected void commit() {
+ Shell activeShell = Display.getCurrent().getActiveShell();
+ if (activeShell != null && getCellEditor().getControl().getShell().equals(activeShell.getParent())) {
+ Control[] children = activeShell.getChildren();
+ if (children.length == 1 && children[0] instanceof Table) {
+ /*
+ * CONTENT ASSIST: focus is lost to the content assist pop up -
+ * stay in focus
+ */
+ getCellEditor().getControl().setVisible(true);
+ ((CellEditorEx) getCellEditor()).setDeactivationLock(true);
+ return;
+ }
+ }
+
+ // content assist hacks
+ if (committed) {
+ bringDown();
+ return;
+ }
+ committed = true;
+ super.commit();
+ }
+
+ /**
+ * @see org.eclipse.gef.tools.DirectEditManager#bringDown()
+ */
+ protected void bringDown() {
+ if (proposalPopupForegroundColor != null) {
+ proposalPopupForegroundColor.dispose();
+ proposalPopupForegroundColor = null;
+ }
+ if (proposalPopupBackgroundColor != null) {
+ proposalPopupBackgroundColor.dispose();
+ proposalPopupBackgroundColor = null;
+ }
+
+ // see - RATLC00523014: crashes when queued in asyncExec()
+ eraseFeedback();
+
+ initialString = new StringBuffer();
+
+ Display.getCurrent().asyncExec(new Runnable() {
+
+ public void run() {
+ // Content Assist hack - allow proper cleanup on childen
+ // controls
+ DirectEditManagerBase.super.bringDown();
+ }
+ });
+
+ for (Iterator iter = cachedFontDescriptors.iterator(); iter.hasNext();) {
+ getResourceManager().destroyFont((FontDescriptor) iter.next());
+ }
+ cachedFontDescriptors.clear();
+ }
+
+ /**
+ * This method is used to set the cell editors text
+ *
+ * @param toEdit
+ * String to be set in the cell editor
+ */
+ public void setEditText(String toEdit) {
+
+ // Get the cell editor
+ CellEditor cellEditor = getCellEditor();
+
+ // IF the cell editor doesn't exist yet...
+ if (cellEditor == null) {
+ // Do nothing
+ return;
+ }
+
+ // Get the Text Compartment Edit Part
+ ITextAwareEditPart textEP = (ITextAwareEditPart) getEditPart();
+
+ // Set the Figures text
+ textEP.setLabelText(toEdit);
+
+ // See RATLC00522324
+ if (cellEditor instanceof CellEditorEx) {
+ ((CellEditorEx) cellEditor).setValueAndProcessEditOccured(toEdit);
+ } else {
+ cellEditor.setValue(toEdit);
+ }
+ }
+
+ /**
+ * Performs show and sets the edit string to be the initial character or
+ * string
+ *
+ * @param initialChar
+ */
+ public void show(char initialChar) {
+ initialString = initialString.append(initialChar);
+ show();
+ if (SWT.getPlatform() != "carbon") { //$NON-NLS-1$
+ // Set the cell editor text to the initial character
+ setEditText(initialString.toString());
+ }
+ }
+
+ /**
+ * This method obtains the fonts that are being used by the figure at its
+ * zoom level.
+ *
+ * @param gep
+ * the associated <code>GraphicalEditPart</code> of the figure
+ * @param actualFont
+ * font being used by the figure
+ * @param display
+ * @return <code>actualFont</code> if zoom level is 1.0 (or when there's an
+ * error), new Font otherwise.
+ */
+ private Font getZoomLevelFont(Font actualFont, Display display) {
+ Object zoom = getEditPart().getViewer().getProperty(ZoomManager.class.toString());
+
+ if (zoom != null) {
+ double zoomLevel = ((ZoomManager) zoom).getZoom();
+
+ if (zoomLevel == 1.0f)
+ return actualFont;
+
+ FontData[] fd = new FontData[actualFont.getFontData().length];
+ FontData tempFD = null;
+
+ for (int i = 0; i < fd.length; i++) {
+ tempFD = actualFont.getFontData()[i];
+
+ fd[i] = new FontData(tempFD.getName(), (int) (zoomLevel * tempFD.getHeight()), tempFD.getStyle());
+ }
+
+ try {
+ FontDescriptor fontDescriptor = FontDescriptor.createFrom(fd);
+ cachedFontDescriptors.add(fontDescriptor);
+ return getResourceManager().createFont(fontDescriptor);
+ } catch (DeviceResourceException e) {
+ Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getZoomLevelFonts", e); //$NON-NLS-1$
+ Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getZoomLevelFonts", e); //$NON-NLS-1$
+
+ return actualFont;
+ }
+ } else
+ return actualFont;
+ }
+
+ public void show() {
+ super.show();
+
+ IFigure fig = getEditPart().getFigure();
+
+ Control control = getCellEditor().getControl();
+ this.zoomLevelFont = getZoomLevelFont(fig.getFont(), control.getDisplay());
+
+ control.setFont(this.zoomLevelFont);
+
+ //since the font's have been resized, we need to resize the Text control...
+ getLocator().relocate(getCellEditor());
+ }
+
+ /**
+ *
+ * Performs show and sends an extra mouse click to the point location so
+ * that cursor appears at the mouse click point
+ *
+ * The Text control does not allow for the cursor to appear at point
+ * location but at a character location
+ *
+ * @param location
+ */
+ public void show(Point location) {
+ show();
+ sendClickToCellEditor(location);
+ }
+
+ private void sendClickToCellEditor(final Point location) {
+ //make sure the diagram doesn't receive the click event..
+ getCellEditor().getControl().setCapture(true);
+
+ if (getCellEditor() != null && getCellEditor().getControl().getBounds().contains(location))
+ sendMouseClick(location);
+ }
+
+ /**
+ *
+ * Sends a SWT MouseUp and MouseDown event to the point location to the
+ * current Display
+ *
+ * @param location
+ */
+ private void sendMouseClick(final Point location) {
+
+ final Display currDisplay = Display.getCurrent();
+ currDisplay.asyncExec(new Runnable() {
+
+ public void run() {
+ Event event;
+ event = new Event();
+ event.type = SWT.MouseDown;
+ event.button = 1;
+ event.x = location.x;
+ event.y = location.y;
+ currDisplay.post(event);
+ event.type = SWT.MouseUp;
+ currDisplay.post(event);
+ }
+ });
+ }
+
+ protected void hookListeners() {
+ super.hookListeners();
+
+ // TODO: This gets around the problem of the cell editor not growing big
+ // enough when in autosize mode because it doesn't listen to textflow
+ // size changes. The superclass should be modified to not assume we want
+ // to listen to the editpart's figure.
+ ILabelDelegate label = (ILabelDelegate) getEditPart().getAdapter(ILabelDelegate.class);
+ if (label != null && getEditPart().getFigure() instanceof WrappingLabel) {
+
+ textFigureListener = new AncestorListener.Stub() {
+
+ public void ancestorMoved(IFigure ancestor) {
+ getLocator().relocate(getCellEditor());
+ }
+ };
+ ((IFigure) ((WrappingLabel) getEditPart().getFigure()).getTextFigure().getChildren().get(0)).addAncestorListener(textFigureListener);
+ }
+ }
+
+ /*
+ * Overrides super unhookListeners to set listeners attached flag This
+ * method prevents unhooking listeners twice if the UI thread is blocked.
+ * For example, a validation dialog may block the thread
+ */
+ protected void unhookListeners() {
+ if (listenersAttached) {
+ listenersAttached = false;
+ super.unhookListeners();
+
+ ILabelDelegate label = (ILabelDelegate) getEditPart().getAdapter(ILabelDelegate.class);
+ if (label != null && textFigureListener != null) {
+ ((IFigure) ((WrappingLabel) getEditPart().getFigure()).getTextFigure().getChildren().get(0)).removeAncestorListener(textFigureListener);
+ textFigureListener = null;
+ }
+ }
+ }
+
+ /*
+ * Sets the listeners attached flag if the cell editor exists
+ */
+ protected void setCellEditor(CellEditor editor) {
+ super.setCellEditor(editor);
+ if (editor != null) {
+ listenersAttached = true;
+ }
+ }
+
+ public void showFeedback() {
+ try {
+ getEditPart().getRoot();
+ super.showFeedback();
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+
+ }
+
+ /**
+ * Gets the resource manager to remember the resources allocated for this
+ * graphical viewer. All resources will be disposed when the graphical
+ * viewer is closed if they have not already been disposed.
+ *
+ * @return
+ */
+ protected ResourceManager getResourceManager() {
+ return ((DiagramGraphicalViewer) getEditPart().getViewer()).getResourceManager();
+ }
+
+ protected abstract CellEditor doCreateCellEditorOn(Composite composite);
+
+ protected abstract void createContentAssistant(Control control, Color proposalPopupForegroundColor, Color proposalPopupBackgroundColor, IContentAssistProcessor processor);
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextCellEditorEx.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextCellEditorEx.java
new file mode 100644
index 000000000..efe0fa17f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextCellEditorEx.java
@@ -0,0 +1,138 @@
+/******************************************************************************
+ * Copyright (c) 2002, 2004, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Svyatoslav Kovalsky (Montages) - contribution for bugzilla 371888
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Extends the TextCellEditor to provide a convenient method
+ * that will permitting the set of the value and doing the necessary
+ * process to update the state of the cell editor and also notify
+ * all listeners listening on changes in the cell editor value.
+ */
+/*public*/ class TextCellEditorEx extends TextCellEditor implements CellEditorEx {
+
+ private CellEditorExDelegate myExDelegate;
+
+ public TextCellEditorEx() {
+ // empty
+ }
+
+ /**
+ * @param parent
+ * the parent control
+ */
+ public TextCellEditorEx(Composite parent) {
+ super(parent);
+ }
+
+ /**
+ * Creates a new text string cell editor parented under the given control.
+ * The cell editor value is the string itself, which is initially the empty
+ * string. Initially, the cell editor has no cell validator.
+ *
+ * @param parent
+ * the parent control
+ * @param style
+ * the style bits
+ */
+ public TextCellEditorEx(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ private CellEditorExDelegate getExDelegate() {
+ if (myExDelegate == null) {
+ myExDelegate = new CellEditorExDelegate(this);
+ }
+ return myExDelegate;
+ }
+
+ /**
+ * This will be used when an edit has occurred by a ModifyEvent has been
+ * been send. Will call #setValue(Object) but will also call
+ * editOccured(null) to make sure that the dirty flag is set probably and
+ * that any listeners are informed about the changed.
+ *
+ * @param value
+ * Value to set the cell editor to.
+ *
+ * Note: This happens address defect RATLC00522324. For our
+ * topgraphical edit parts we delagate the direct edit request to
+ * a primary edit part and set focus on that. The issue is that
+ * if the user has typed in an initial character when setting
+ * focus to the edit part, which typically is a
+ * TextCompartmentEditPart then setting that intial value does
+ * not fire the necessary change events that need to occur in
+ * order for that value to be recongnized. If you don't use this
+ * method then the result is that if you just type in the initial
+ * character and that is it then the text compartment loses focus
+ * then the value will not be saved. This is because setting the
+ * value of the cell doesn't think its value has changed since
+ * the first character is not recongized as a change.
+ */
+ public void setValueAndProcessEditOccured(Object value) {
+ setValue(value);
+ // do the processing to ensure if we exit the cell then
+ // value will be applied.
+ editOccured(null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.CellEditor#doSetValue(java.lang.Object)
+ */
+ protected void doSetValue(Object value) {
+ getExDelegate().setOriginalValue(value);
+ super.doSetValue(value);
+ }
+
+ /**
+ * @return boolean value specifying whether or not the value has been
+ * changed
+ */
+ public boolean hasValueChanged() {
+ return getExDelegate().hasValueChanged();
+ }
+
+ /*
+ * Runs super deactivate unless it has been locked and otherwise unlocks
+ * deactivation
+ *
+ * @see org.eclipse.jface.viewers.CellEditor#deactivate()
+ */
+ public void deactivate() {
+ if (!getExDelegate().unlockDeactivation()) {
+ super.deactivate();
+ }
+ }
+
+ /**
+ * Returns true if deactivation has been locked
+ * @return
+ */
+ public boolean isDeactivationLocked() {
+ return getExDelegate().isDeactivationLocked();
+ }
+
+ /**
+ * Sets deactivation lock so that the cell editor does not perform
+ * deactivate
+ *
+ * @param deactivationLock
+ */
+ public void setDeactivationLock(boolean deactivationLock) {
+ getExDelegate().setDeactivationLock(deactivationLock);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextDirectEditManager2.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextDirectEditManager2.java
new file mode 100644
index 000000000..7e16e202d
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/TextDirectEditManager2.java
@@ -0,0 +1,208 @@
+/******************************************************************************
+ * Copyright (c) 2002, 2010, 2012 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Dmitry Stadnik (Borland) - contribution for bugzilla 135694
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.gmf.runtime.common.ui.contentassist.ContentAssistantHelper;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.label.ILabelDelegate;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.part.CellEditorActionHandler;
+
+/**
+ * @author melaasar
+ */
+public class TextDirectEditManager2 extends DirectEditManagerBase {
+
+ private IAction copy, cut, paste, undo, redo, find, selectAll, delete;
+
+ private IActionBars actionBars;
+
+ private CellEditorActionHandler actionHandler;
+
+ /**
+ * constructor
+ *
+ * @param source
+ * <code>GraphicalEditPart</code> to support direct edit of. The
+ * figure of the <code>source</code> edit part must be of type
+ * <code>WrapLabel</code>.
+ */
+ public TextDirectEditManager2(ITextAwareEditPart source) {
+ super(source);
+ }
+
+ /**
+ * @param source
+ * @param editorType
+ * @param locator
+ */
+ public TextDirectEditManager2(GraphicalEditPart source, Class editorType, CellEditorLocator locator) {
+ super(source, editorType, locator);
+ }
+
+ /**
+ * @param source
+ * the <code>ITextAwareEditPart</code> to determine the cell
+ * editor for
+ * @return the <code>CellEditorLocator</code> that is appropriate for the
+ * source <code>EditPart</code>
+ */
+ public static CellEditorLocator getTextCellEditorLocator(final ITextAwareEditPart source) {
+ return getCellEditorLocator(source);
+ }
+
+ /**
+ * @param source
+ * the <code>GraphicalEditPart</code> that is used to determine
+ * which <code>CellEditor</code> class to use.
+ * @return the <code>Class</code> of the <code>CellEditor</code> to use for
+ * the text editing.
+ * @deprecated to override the cell editor class, use
+ * {@link #createCellEditorOn(Composite)}, this provides the
+ * flexibility necessary to initialize the cell editor with a
+ * style.
+ */
+ public static Class getTextCellEditorClass(GraphicalEditPart source) {
+ IFigure figure = source.getFigure();
+
+ if (figure instanceof WrapLabel && ((WrapLabel) figure).isTextWrapped())
+ return WrapTextCellEditor.class;
+
+ return TextCellEditorEx.class;
+ }
+
+ protected CellEditor doCreateCellEditorOn(Composite composite) {
+ ILabelDelegate label = (ILabelDelegate) getEditPart().getAdapter(ILabelDelegate.class);
+ if (label != null && label.isTextWrapOn()) {
+ int style = SWT.WRAP | SWT.MULTI;
+
+ switch (label.getTextJustification()) {
+ case PositionConstants.LEFT:
+ style = style | SWT.LEAD;
+ break;
+ case PositionConstants.RIGHT:
+ style = style | SWT.TRAIL;
+ break;
+ case PositionConstants.CENTER:
+ style = style | SWT.CENTER;
+ break;
+ default:
+ break;
+ }
+ return new WrapTextCellEditor(composite, style);
+ } else {
+ return new TextCellEditorEx(composite);
+ }
+ }
+
+ /**
+ * This method is used to set the cell editors text
+ *
+ * @param toEdit
+ * String to be set in the cell editor
+ */
+ @Override
+ public void setEditText(String toEdit) {
+ super.setEditText(toEdit);
+
+ // Get the cell editor
+ CellEditor cellEditor = getCellEditor();
+
+ // IF the cell editor doesn't exist yet...
+ if (cellEditor == null) {
+ // Do nothing
+ return;
+ }
+
+ // Get the Text control
+ Text textControl = (Text) cellEditor.getControl();
+
+ // Set the controls text and position the caret at the end of the text
+ textControl.setSelection(toEdit.length());
+ }
+
+ @Override
+ protected void createContentAssistant(Control control, Color proposalPopupForegroundColor, Color proposalPopupBackgroundColor, IContentAssistProcessor processor) {
+ ContentAssistantHelper.createTextContentAssistant((Text) control, proposalPopupForegroundColor, proposalPopupBackgroundColor, processor);
+ }
+
+ @Override
+ protected void initCellEditor() {
+ super.initCellEditor();
+
+ //Hook the cell editor's copy/paste actions to the actionBars so that they can
+ // be invoked via keyboard shortcuts.
+ actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
+ saveCurrentActions(actionBars);
+ actionHandler = new CellEditorActionHandler(actionBars);
+ actionHandler.addCellEditor(getCellEditor());
+ actionBars.updateActionBars();
+
+ }
+
+ /**
+ * @see org.eclipse.gef.tools.DirectEditManager#bringDown()
+ */
+ @Override
+ protected void bringDown() {
+ super.bringDown();
+
+ if (actionHandler != null) {
+ actionHandler.dispose();
+ actionHandler = null;
+ }
+ if (actionBars != null) {
+ restoreSavedActions(actionBars);
+ actionBars.updateActionBars();
+ actionBars = null;
+ }
+ }
+
+ private void saveCurrentActions(IActionBars _actionBars) {
+ copy = _actionBars.getGlobalActionHandler(ActionFactory.COPY.getId());
+ paste = _actionBars.getGlobalActionHandler(ActionFactory.PASTE.getId());
+ delete = _actionBars.getGlobalActionHandler(ActionFactory.DELETE.getId());
+ selectAll = _actionBars.getGlobalActionHandler(ActionFactory.SELECT_ALL.getId());
+ cut = _actionBars.getGlobalActionHandler(ActionFactory.CUT.getId());
+ find = _actionBars.getGlobalActionHandler(ActionFactory.FIND.getId());
+ undo = _actionBars.getGlobalActionHandler(ActionFactory.UNDO.getId());
+ redo = _actionBars.getGlobalActionHandler(ActionFactory.REDO.getId());
+ }
+
+ private void restoreSavedActions(IActionBars _actionBars) {
+ _actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copy);
+ _actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), paste);
+ _actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), delete);
+ _actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAll);
+ _actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cut);
+ _actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), find);
+ _actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undo);
+ _actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redo);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/WrapTextCellEditor.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/WrapTextCellEditor.java
new file mode 100644
index 000000000..a28078c2b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/directedit/WrapTextCellEditor.java
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * Copyright (c) 2002, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ****************************************************************************/
+
+package org.eclipse.gmf.tooling.runtime.directedit;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A cell editor that manages a multiline wrappable text entry field.
+ * The cell editor's value is the text string itself.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ */
+public class WrapTextCellEditor extends TextCellEditorEx {
+
+ /**
+ * Default MultiLineTextCellEditor style
+ * specify no borders on text widget as cell outline in table already
+ * provides the look of a border.
+ */
+ private static final int defaultStyle = SWT.WRAP | SWT.MULTI;
+
+ /**
+ * Creates a new text string cell editor with no control
+ * The cell editor value is the string itself, which is initially the empty
+ * string. Initially, the cell editor has no cell validator.
+ */
+ public WrapTextCellEditor() {
+ setStyle(defaultStyle);
+ }
+ /**
+ * Creates a new text string cell editor parented under the given control.
+ * The cell editor value is the string itself, which is initially the empty string.
+ * Initially, the cell editor has no cell validator.
+ *
+ * @param parent the parent control
+ */
+ public WrapTextCellEditor(Composite parent) {
+ this(parent, defaultStyle);
+ }
+ /**
+ * Creates a new text string cell editor parented under the given control.
+ * The cell editor value is the string itself, which is initially the empty string.
+ * Initially, the cell editor has no cell validator.
+ *
+ * @param parent the parent control
+ * @param style the style bits
+ */
+ public WrapTextCellEditor(Composite parent, int style) {
+ super(parent, style);
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.CellEditor#keyReleaseOccured(org.eclipse.swt.events.KeyEvent)
+ */
+ protected void keyReleaseOccured(KeyEvent keyEvent) {
+ // The super behavior of this method is to apply the cell editor value
+ // if the 'Return' key is pressed with the 'CTRL' key. Otherwise, the
+ // 'Return' key is used to insert a new line. This is exactly opposite
+ // to what we expect in this editor and that is why we are reversing it.
+ if (keyEvent.character == '\r') {
+ if ((keyEvent.stateMask & SWT.CTRL) != 0)
+ keyEvent.stateMask &= ~SWT.CTRL;
+ else
+ keyEvent.stateMask |= SWT.CTRL;
+ }
+ super.keyReleaseOccured(keyEvent);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclDependencyCollector.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclDependencyCollector.java
new file mode 100644
index 000000000..068339d57
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclDependencyCollector.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public interface ActiveOclDependencyCollector {
+
+ public void registerDependency(EObject context, EStructuralFeature feature);
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclEvaluator.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclEvaluator.java
new file mode 100644
index 000000000..12257b930
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclEvaluator.java
@@ -0,0 +1,11 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ocl.ParserException;
+
+public interface ActiveOclEvaluator {
+
+ ActiveOclResult evaluate(EObject context, String oclExp) throws ParserException;
+
+ Object evaluate(EObject context, String oclExp, ActiveOclDependencyCollector dependencyCollector) throws ParserException;
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclListener.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclListener.java
new file mode 100644
index 000000000..eec6fa41e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclListener.java
@@ -0,0 +1,6 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl;
+
+public interface ActiveOclListener {
+
+ void onResultChanged();
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclResult.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclResult.java
new file mode 100644
index 000000000..b0c09c7f5
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/activeocl/ActiveOclResult.java
@@ -0,0 +1,18 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl;
+
+import org.eclipse.emf.common.notify.Notifier;
+
+public interface ActiveOclResult {
+
+ Object getResult();
+
+ boolean canListenForChanges();
+
+ void addListener(ActiveOclListener listener);
+
+ void removeListener(ActiveOclListener listener);
+
+ Notifier adaptToEMFNotifier();
+
+ void dispose();
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclDependencyCollectorBase.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclDependencyCollectorBase.java
new file mode 100644
index 000000000..5618352f4
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclDependencyCollectorBase.java
@@ -0,0 +1,39 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclDependencyCollector;
+
+abstract class ActiveOclDependencyCollectorBase<T extends ContextData> implements ActiveOclDependencyCollector {
+
+ private final Map<EObject, T> myContext2Data;
+
+ public ActiveOclDependencyCollectorBase() {
+ myContext2Data = new HashMap<EObject, T>();
+ }
+
+ @Override
+ public void registerDependency(EObject context, EStructuralFeature feature) {
+ T contextData = myContext2Data.get(context);
+
+ if (contextData == null) {
+ contextData = createContextData(context);
+ myContext2Data.put(context, contextData);
+ }
+
+ contextData.addFeature(feature);
+ }
+
+ public void clear() {
+ myContext2Data.clear();
+ }
+
+ public Map<EObject, T> getContext2Data() {
+ return myContext2Data;
+ }
+
+ protected abstract T createContextData(EObject context);
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclEvaluatorImpl.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclEvaluatorImpl.java
new file mode 100644
index 000000000..0e195c02f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclEvaluatorImpl.java
@@ -0,0 +1,20 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclDependencyCollector;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclEvaluator;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclResult;
+import org.eclipse.ocl.ParserException;
+
+class ActiveOclEvaluatorImpl implements ActiveOclEvaluator {
+
+ @Override
+ public ActiveOclResult evaluate(EObject context, String oclExp) throws ParserException {
+ return new ActiveOclResultImpl(context, oclExp);
+ }
+
+ @Override
+ public Object evaluate(EObject context, String oclExp, ActiveOclDependencyCollector dependencyCollector) throws ParserException {
+ return new DependencyEvaluator(context, oclExp, dependencyCollector).evaluate();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclResultImpl.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclResultImpl.java
new file mode 100644
index 000000000..2ae5916f0
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclResultImpl.java
@@ -0,0 +1,78 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclListener;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclResult;
+import org.eclipse.ocl.ParserException;
+
+class ActiveOclResultImpl implements ActiveOclResult, ActiveOclListener {
+
+ private final List<ActiveOclListener> myListeners;
+
+ private Object myResult;
+
+ private final ListeningDependencyCollector myDependencyCollector;
+
+ private final DependencyEvaluator myDependencyEvaluator;
+
+ public ActiveOclResultImpl(EObject context, String oclExp) throws ParserException {
+ myListeners = new ArrayList<ActiveOclListener>();
+
+ myDependencyCollector = new ListeningDependencyCollector(this);
+
+ myDependencyEvaluator = new DependencyEvaluator(context, oclExp, myDependencyCollector);
+
+ myResult = myDependencyEvaluator.evaluate();
+ }
+
+ @Override
+ public void onResultChanged() {
+ myDependencyCollector.clear();
+
+ Object newResult = myDependencyEvaluator.evaluate();
+ if (myResult == null && newResult == null //
+ || myResult != null && myResult.equals(newResult)) {
+ return;
+ }
+ myResult = newResult;
+
+ for (ActiveOclListener listener : myListeners) {
+ listener.onResultChanged();
+ }
+ }
+
+ @Override
+ public void removeListener(ActiveOclListener listener) {
+ myListeners.remove(listener);
+ }
+
+ @Override
+ public Object getResult() {
+ return myResult;
+ }
+
+ @Override
+ public void dispose() {
+ myDependencyCollector.clear();
+ }
+
+ @Override
+ public boolean canListenForChanges() {
+ return true;
+ }
+
+ @Override
+ public void addListener(ActiveOclListener listener) {
+ myListeners.add(listener);
+ }
+
+ @Override
+ public Notifier adaptToEMFNotifier() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTracker.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTracker.java
new file mode 100644
index 000000000..420686534
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTracker.java
@@ -0,0 +1,100 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerBase;
+import org.eclipse.ocl.ParserException;
+
+class ActiveOclTracker extends OclTrackerBase {
+
+ private NotificationListener myListener;
+
+ private SimpleDependencyCollector myDependecyCollector;
+
+ private List<EObject> myParserElements;
+
+ private Registrator myRegistrator;
+
+ private Object myValue;
+
+ private boolean myValueInitialized = false;
+
+ private final boolean myCached;
+
+ public ActiveOclTracker(String expressionBody, boolean cached) {
+ super(expressionBody);
+ myCached = cached;
+ myDependecyCollector = new SimpleDependencyCollector();
+ }
+
+ @Override
+ public void installListeners(TransactionalEditingDomain domain, NotificationListener listener, Registrator registrator) {
+ myListener = listener;
+ myRegistrator = registrator;
+
+ registerListeners();
+ }
+
+ @Override
+ public void uninstallListeners() {
+ unregisterListeners();
+ }
+
+ private void registerListeners() {
+ if (myRegistrator == null) {
+ return;
+ }
+ myParserElements = new ArrayList<EObject>(myDependecyCollector.getContext2Data().keySet());
+ for (int i = 0; i < myParserElements.size(); i++) {
+ myRegistrator.registerListener("ActiveOclTracker#SemanticModel" + i, myListener, myParserElements.get(i)); //$NON-NLS-1$
+ }
+ }
+
+ private void unregisterListeners() {
+ if (myParserElements == null) {
+ return;
+ }
+ for (int i = 0; i < myParserElements.size(); i++) {
+ myRegistrator.unregisterListener("ActiveOclTracker#SemanticModel" + i); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public Object getValue() {
+ if (!myValueInitialized || !isCached()) {
+ doInitialize();
+ }
+ return myValue;
+ }
+
+ @Override
+ public boolean handleNotification(Notification notification) {
+ ContextData contextData = myDependecyCollector.getContext2Data().get(notification.getNotifier());
+ boolean affected = contextData != null && contextData.getFeatures().contains(notification.getFeature());
+ if (affected) {
+ doInitialize();
+ }
+ return affected;
+ }
+
+ @Override
+ protected void doInitialize() {
+ unregisterListeners();
+ myDependecyCollector.clear();
+ try {
+ myValue = new ActiveOclEvaluatorImpl().evaluate(getContext(), getExpressionBody(), myDependecyCollector);
+ } catch (ParserException e) {
+ throw new RuntimeException(e);
+ }
+ registerListeners();
+ }
+
+ private boolean isCached() {
+ return myCached;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTrackerFactory.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTrackerFactory.java
new file mode 100644
index 000000000..bf0bfdafa
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ActiveOclTrackerFactory.java
@@ -0,0 +1,17 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+
+public class ActiveOclTrackerFactory implements OclTrackerFactory {
+
+ @Override
+ public OclTracker createOclTracker(String expressionBody, boolean cached) {
+ return new ActiveOclTracker(expressionBody, cached);
+ }
+
+ @Override
+ public Type getImplementationType() {
+ return Type.DEFAULT_GMFT;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextData.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextData.java
new file mode 100644
index 000000000..62e5a9668
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextData.java
@@ -0,0 +1,31 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+class ContextData {
+
+ private final EObject myContext;
+
+ private final Set<EStructuralFeature> myFeatures;
+
+ public ContextData(EObject context) {
+ myContext = context;
+ myFeatures = new HashSet<EStructuralFeature>();
+ }
+
+ public void addFeature(EStructuralFeature feature) {
+ myFeatures.add(feature);
+ }
+
+ public Set<EStructuralFeature> getFeatures() {
+ return myFeatures;
+ }
+
+ public EObject getContext() {
+ return myContext;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextDataWithAdapter.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextDataWithAdapter.java
new file mode 100644
index 000000000..057fb28cc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ContextDataWithAdapter.java
@@ -0,0 +1,35 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+
+class ContextDataWithAdapter extends org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl.ContextData {
+
+ private final Adapter myAdapter;
+
+ public ContextDataWithAdapter(EObject context, final org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclListener listener) {
+ super(context);
+ myAdapter = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (getFeatures().contains(notification.getFeature())) {
+ listener.onResultChanged();
+ }
+ }
+
+ @Override
+ public boolean isAdapterForType(Object type) {
+ return true;
+ }
+ };
+
+ getContext().eAdapters().add(myAdapter);
+ }
+
+ public void dispose() {
+ getContext().eAdapters().remove(myAdapter);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/DependencyEvaluator.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/DependencyEvaluator.java
new file mode 100644
index 000000000..6db1a00e1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/DependencyEvaluator.java
@@ -0,0 +1,29 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ocl.ParserException;
+import org.eclipse.ocl.ecore.OCL.Helper;
+import org.eclipse.ocl.ecore.OCLExpression;
+
+class DependencyEvaluator {
+
+ private final EObject myContext;
+
+ private final org.eclipse.ocl.ecore.OCL myOcl;
+
+ private final OCLExpression myExpression;
+
+ public DependencyEvaluator(EObject context, String oclExp, org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclDependencyCollector dependencyCollector) throws ParserException {
+ myContext = context;
+
+ myOcl = org.eclipse.ocl.ecore.OCL.newInstance(new org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl.EcoreEnvironmentFactoryEx(dependencyCollector));
+
+ Helper helper = myOcl.createOCLHelper();
+ helper.setContext(context.eClass());
+ myExpression = helper.createQuery(oclExp);
+ }
+
+ public Object evaluate() {
+ return myOcl.evaluate(myContext, myExpression);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EcoreEnvironmentFactoryEx.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EcoreEnvironmentFactoryEx.java
new file mode 100644
index 000000000..c69cdbc79
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EcoreEnvironmentFactoryEx.java
@@ -0,0 +1,50 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclDependencyCollector;
+import org.eclipse.ocl.Environment;
+import org.eclipse.ocl.EvaluationEnvironment;
+import org.eclipse.ocl.EvaluationVisitor;
+import org.eclipse.ocl.ecore.CallOperationAction;
+import org.eclipse.ocl.ecore.Constraint;
+import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
+import org.eclipse.ocl.ecore.SendSignalAction;
+import org.eclipse.ocl.internal.evaluation.TracingEvaluationVisitor;
+
+class EcoreEnvironmentFactoryEx extends EcoreEnvironmentFactory {
+
+ private final ActiveOclDependencyCollector myDependencyCollector;
+
+ public EcoreEnvironmentFactoryEx(org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclDependencyCollector dependencyCollector) {
+ myDependencyCollector = dependencyCollector;
+ }
+
+ @Override
+ public EvaluationVisitor<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> createEvaluationVisitor(
+ Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> env,
+ EvaluationEnvironment<EClassifier, EOperation, EStructuralFeature, EClass, EObject> evalEnv, Map<? extends EClass, ? extends Set<? extends EObject>> extentMap) {
+
+ EvaluationVisitorImplEx evaluationVisitorImplEx = new EvaluationVisitorImplEx(env, evalEnv, extentMap, myDependencyCollector);
+ EvaluationVisitor<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> result = evaluationVisitorImplEx;
+
+ if (isEvaluationTracingEnabled()) {
+ result = decorateWithTracingSupport(result);
+ }
+ return result;
+ }
+
+ private static <PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> //
+ EvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> decorateWithTracingSupport(EvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> base) {
+ return new TracingEvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E>(base);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EvaluationVisitorImplEx.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EvaluationVisitorImplEx.java
new file mode 100644
index 000000000..211893371
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/EvaluationVisitorImplEx.java
@@ -0,0 +1,50 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.ocl.Environment;
+import org.eclipse.ocl.EvaluationEnvironment;
+import org.eclipse.ocl.ecore.CallOperationAction;
+import org.eclipse.ocl.ecore.Constraint;
+import org.eclipse.ocl.ecore.EvaluationVisitorImpl;
+import org.eclipse.ocl.ecore.SendSignalAction;
+import org.eclipse.ocl.ecore.impl.PropertyCallExpImpl;
+import org.eclipse.ocl.expressions.OCLExpression;
+import org.eclipse.ocl.expressions.PropertyCallExp;
+
+public class EvaluationVisitorImplEx extends EvaluationVisitorImpl {
+
+ private final org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclDependencyCollector myDependencyCollector;
+
+ public EvaluationVisitorImplEx(
+ Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> env, //
+ EvaluationEnvironment<EClassifier, EOperation, EStructuralFeature, EClass, EObject> evalEnv, Map<? extends EClass, ? extends Set<? extends EObject>> extentMap, //
+ org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclDependencyCollector dependencyCollector) {
+ super(env, evalEnv, extentMap);
+ myDependencyCollector = dependencyCollector;
+ }
+
+ @Override
+ public Object visitPropertyCallExp(PropertyCallExp<EClassifier, EStructuralFeature> pc) {
+ PropertyCallExpImpl pcImpl = (PropertyCallExpImpl) pc;
+
+ final EStructuralFeature feature = pcImpl.getReferredProperty();
+
+ OCLExpression<EClassifier> source = pc.getSource();
+
+ EObject context = (EObject) source.accept(getVisitor());
+
+ myDependencyCollector.registerDependency(context, feature);
+
+ return super.visitPropertyCallExp(pc);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ListeningDependencyCollector.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ListeningDependencyCollector.java
new file mode 100644
index 000000000..83ad87939
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/ListeningDependencyCollector.java
@@ -0,0 +1,25 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.tooling.runtime.impl.ocl.activeocl.ActiveOclListener;
+
+class ListeningDependencyCollector extends ActiveOclDependencyCollectorBase<ContextDataWithAdapter> {
+
+ private final ActiveOclListener myListener;
+
+ public ListeningDependencyCollector(ActiveOclListener listener) {
+ myListener = listener;
+ }
+
+ @Override
+ protected ContextDataWithAdapter createContextData(EObject context) {
+ return new ContextDataWithAdapter(context, myListener);
+ }
+
+ public void clear() {
+ for (ContextDataWithAdapter contextData : getContext2Data().values()) {
+ contextData.dispose();
+ }
+ super.clear();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/SimpleDependencyCollector.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/SimpleDependencyCollector.java
new file mode 100644
index 000000000..e5d7fd486
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/impl/ocl/tracker/activeocl/SimpleDependencyCollector.java
@@ -0,0 +1,11 @@
+package org.eclipse.gmf.tooling.runtime.impl.ocl.tracker.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+
+class SimpleDependencyCollector extends ActiveOclDependencyCollectorBase<ContextData> {
+
+ @Override
+ protected ContextData createContextData(EObject context) {
+ return new ContextData(context);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/HasOclTracker.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/HasOclTracker.java
new file mode 100644
index 000000000..d547945b0
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/HasOclTracker.java
@@ -0,0 +1,6 @@
+package org.eclipse.gmf.tooling.runtime.ocl.tracker;
+
+public interface HasOclTracker {
+
+ public OclTracker getOclTracker();
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTracker.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTracker.java
new file mode 100644
index 000000000..8f2a9db24
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTracker.java
@@ -0,0 +1,29 @@
+package org.eclipse.gmf.tooling.runtime.ocl.tracker;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+
+public interface OclTracker {
+
+ public void initialize(EObject context);
+
+ public void installListeners(TransactionalEditingDomain domain, NotificationListener listener, Registrator registrator);
+
+ public void uninstallListeners();
+
+ public Object getValue();
+
+ public boolean handleNotification(Notification notification);
+
+ public String getExpressionBody();
+
+ public interface Registrator {
+
+ public void registerListener(String filterId, NotificationListener listener, EObject element);
+
+ public void unregisterListener(String filterId);
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerBase.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerBase.java
new file mode 100644
index 000000000..76bbadc65
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerBase.java
@@ -0,0 +1,34 @@
+package org.eclipse.gmf.tooling.runtime.ocl.tracker;
+
+import org.eclipse.emf.ecore.EObject;
+
+public abstract class OclTrackerBase implements OclTracker {
+
+ private EObject myContext;
+
+ private final String myExpressionBody;
+
+ protected OclTrackerBase(String expressionBody) {
+ myExpressionBody = expressionBody;
+ }
+
+ @Override
+ public final String getExpressionBody() {
+ return myExpressionBody;
+ }
+
+ @Override
+ public final void initialize(EObject context) {
+ if (myContext == context) {
+ return;
+ }
+ myContext = context;
+ doInitialize();
+ }
+
+ protected final EObject getContext() {
+ return myContext;
+ }
+
+ protected abstract void doInitialize();
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerFactory.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerFactory.java
new file mode 100644
index 000000000..27eac5357
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/tracker/OclTrackerFactory.java
@@ -0,0 +1,14 @@
+package org.eclipse.gmf.tooling.runtime.ocl.tracker;
+
+
+public interface OclTrackerFactory {
+
+ public OclTracker createOclTracker(String expressionBody, boolean cached);
+
+ public Type getImplementationType();
+
+ public static enum Type {
+ ANY, DEFAULT_GMFT, IMPACT_ANALYZER
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractAttributeParser.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractAttributeParser.java
new file mode 100644
index 000000000..5d6bcea23
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractAttributeParser.java
@@ -0,0 +1,227 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.tooling.runtime.Messages;
+import org.eclipse.osgi.util.NLS;
+
+public abstract class AbstractAttributeParser extends AbstractFeatureParser {
+
+ private String viewPattern;
+
+ private String editorPattern;
+
+ private String editPattern;
+
+ protected final EAttribute[] features;
+
+ protected final EAttribute[] editableFeatures;
+
+ public AbstractAttributeParser(EAttribute[] features) {
+ super(features);
+ this.features = this.editableFeatures = features;
+ }
+
+ public AbstractAttributeParser(EAttribute[] features, EAttribute[] editableFeatures) {
+ super(features, editableFeatures);
+ this.features = features;
+ this.editableFeatures = editableFeatures;
+ }
+
+ @Override
+ protected Object getValue(EObject element, EStructuralFeature feature) {
+ Object value = super.getValue(element, feature);
+ Class<?> iClass = ((EAttribute) feature).getEAttributeType().getInstanceClass();
+ if (String.class.equals(iClass)) {
+ if (value == null) {
+ value = ""; //$NON-NLS-1$
+ }
+ }
+ return value;
+ }
+
+ @Override
+ protected Object getValidNewValue(EStructuralFeature feature, Object value) {
+ EClassifier type = feature.getEType();
+ if (type instanceof EDataType) {
+ Class<?> iClass = type.getInstanceClass();
+ if (Boolean.TYPE.equals(iClass)) {
+ if (value instanceof Boolean) {
+ // ok
+ } else if (value instanceof String) {
+ value = Boolean.valueOf((String) value);
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (Character.TYPE.equals(iClass)) {
+ if (value instanceof Character) {
+ // ok
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ value = new Character(s.charAt(0));
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (Byte.TYPE.equals(iClass)) {
+ if (value instanceof Byte) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Byte(((Number) value).byteValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Byte.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_WrongStringConversion, iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (Short.TYPE.equals(iClass)) {
+ if (value instanceof Short) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Short(((Number) value).shortValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Short.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_WrongStringConversion, iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (Integer.TYPE.equals(iClass)) {
+ if (value instanceof Integer) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Integer(((Number) value).intValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Integer.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_WrongStringConversion, iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (Long.TYPE.equals(iClass)) {
+ if (value instanceof Long) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Long(((Number) value).longValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Long.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_WrongStringConversion, iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (Float.TYPE.equals(iClass)) {
+ if (value instanceof Float) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Float(((Number) value).floatValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Float.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_WrongStringConversion, iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (Double.TYPE.equals(iClass)) {
+ if (value instanceof Double) {
+ // ok
+ } else if (value instanceof Number) {
+ value = new Double(((Number) value).doubleValue());
+ } else if (value instanceof String) {
+ String s = (String) value;
+ if (s.length() == 0) {
+ value = null;
+ } else {
+ try {
+ value = Double.valueOf(s);
+ } catch (NumberFormatException nfe) {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_WrongStringConversion, iClass.getName()));
+ }
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, iClass.getName()));
+ }
+ } else if (type instanceof EEnum) {
+ if (value instanceof String) {
+ EEnumLiteral literal = ((EEnum) type).getEEnumLiteralByLiteral((String) value);
+ if (literal == null) {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnknownLiteral, value));
+ } else {
+ value = literal.getInstance();
+ }
+ } else {
+ value = new InvalidValue(NLS.bind(Messages.AbstractAttributeParser_UnexpectedValueType, String.class.getName()));
+ }
+ }
+ }
+ return value;
+ }
+
+ public String getViewPattern() {
+ return viewPattern;
+ }
+
+ public void setViewPattern(String viewPattern) {
+ this.viewPattern = viewPattern;
+ }
+
+ public String getEditorPattern() {
+ return editorPattern;
+ }
+
+ public void setEditorPattern(String editorPattern) {
+ this.editorPattern = editorPattern;
+ }
+
+ public String getEditPattern() {
+ return editPattern;
+ }
+
+ public void setEditPattern(String editPattern) {
+ this.editPattern = editPattern;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractFeatureParser.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractFeatureParser.java
new file mode 100644
index 000000000..c370ec326
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractFeatureParser.java
@@ -0,0 +1,145 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.tooling.runtime.GMFToolingRuntimePlugin;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+
+public abstract class AbstractFeatureParser implements IParser {
+
+ private final EStructuralFeature[] features;
+
+ private final EStructuralFeature[] editableFeatures;
+
+ public AbstractFeatureParser(EStructuralFeature[] features) {
+ this(features, features);
+ }
+
+ public AbstractFeatureParser(EStructuralFeature[] features, EStructuralFeature[] editableFeatures) {
+ if (features == null || Arrays.asList(features).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ if (editableFeatures == null || Arrays.asList(editableFeatures).contains(null)) {
+ throw new IllegalArgumentException();
+ }
+ this.features = features;
+ this.editableFeatures = editableFeatures;
+ }
+
+ protected EStructuralFeature[] getFeatures() {
+ return features;
+ }
+
+ protected EStructuralFeature[] getEditableFeatures() {
+ return editableFeatures;
+ }
+
+ protected Object[] getValues(EObject element) {
+ Object[] values = new Object[features.length];
+ for (int i = 0; i < features.length; i++) {
+ values[i] = getValue(element, features[i]);
+ }
+ return values;
+ }
+
+ protected Object[] getEditableValues(EObject element) {
+ Object[] values = new Object[editableFeatures.length];
+ for (int i = 0; i < editableFeatures.length; i++) {
+ values[i] = getValue(element, editableFeatures[i]);
+ }
+ return values;
+ }
+
+ protected Object getValue(EObject element, EStructuralFeature feature) {
+ return element.eGet(feature);
+ }
+
+ protected ICommand getParseCommand(IAdaptable adapter, Object[] values, int flags) {
+ if (values == null || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
+ if (editingDomain == null) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
+ for (int i = 0; i < values.length; i++) {
+ command.compose(getModificationCommand(element, editableFeatures[i], values[i]));
+ }
+ return command;
+ }
+
+ protected IParserEditStatus validateNewValues(Object[] values) {
+ if (values.length != editableFeatures.length) {
+ return ParserEditStatus.UNEDITABLE_STATUS;
+ }
+ for (int i = 0; i < values.length; i++) {
+ Object value = getValidNewValue(editableFeatures[i], values[i]);
+ if (value instanceof InvalidValue) {
+ return new ParserEditStatus(GMFToolingRuntimePlugin.ID, IParserEditStatus.UNEDITABLE, value.toString());
+ }
+ }
+ return ParserEditStatus.EDITABLE_STATUS;
+ }
+
+ protected Object getValidNewValue(EStructuralFeature feature, Object value) {
+ return value;
+ }
+
+ protected ICommand getModificationCommand(EObject element, EStructuralFeature feature, Object value) {
+ value = getValidNewValue(feature, value);
+ if (value instanceof InvalidValue) {
+ return UnexecutableCommand.INSTANCE;
+ }
+ SetRequest request = new SetRequest(element, feature, value);
+ return new SetValueCommand(request);
+ }
+
+ public boolean isAffectingEvent(Object event, int flags) {
+ if (event instanceof Notification) {
+ return isAffectingFeature(((Notification) event).getFeature());
+ }
+ return false;
+ }
+
+ protected boolean isAffectingFeature(Object feature) {
+ for (int i = 0; i < features.length; i++) {
+ if (features[i] == feature) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
+ return null;
+ }
+
+ protected class InvalidValue {
+
+ private String description;
+
+ public InvalidValue(String description) {
+ this.description = description;
+ }
+
+ public String toString() {
+ return description;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractParser.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractParser.java
deleted file mode 100644
index 778dc64c7..000000000
--- a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/AbstractParser.java
+++ /dev/null
@@ -1,418 +0,0 @@
-package org.eclipse.gmf.tooling.runtime.parsers;
-
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.gmf.tooling.runtime.GMFToolingRuntimePlugin;
-import org.eclipse.gmf.tooling.runtime.Messages;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @generated
- */
-public abstract class AbstractParser implements IParser {
-
- /**
- * @generated
- */
- protected final EAttribute[] features;
-
- /**
- * @generated
- */
- protected final EAttribute[] editableFeatures;
-
- /**
- * @generated
- */
- private String viewPattern;
-
- /**
- * @generated
- */
- private String editorPattern;
-
- /**
- * @generated
- */
- private String editPattern;
-
- /**
- * @generated
- */
- public AbstractParser(EAttribute[] features) {
- if (features == null || Arrays.asList(features).contains(null)) {
- throw new IllegalArgumentException();
- }
- this.editableFeatures = this.features = features;
- }
-
- /**
- * @generated
- */
- public AbstractParser(EAttribute[] features, EAttribute[] editableFeatures) {
- if (features == null || Arrays.asList(features).contains(null)) {
- throw new IllegalArgumentException();
- }
- this.features = features;
- if (editableFeatures == null || Arrays.asList(editableFeatures).contains(null)) {
- throw new IllegalArgumentException();
- }
- this.editableFeatures = editableFeatures;
- }
-
- /**
- * @generated
- */
- public String getViewPattern() {
- return viewPattern;
- }
-
- /**
- * @generated
- */
- public void setViewPattern(String viewPattern) {
- this.viewPattern = viewPattern;
- }
-
- /**
- * @generated
- */
- public String getEditorPattern() {
- return editorPattern;
- }
-
- /**
- * @generated
- */
- public void setEditorPattern(String editorPattern) {
- this.editorPattern = editorPattern;
- }
-
- /**
- * @generated
- */
- public String getEditPattern() {
- return editPattern;
- }
-
- /**
- * @generated
- */
- public void setEditPattern(String editPattern) {
- this.editPattern = editPattern;
- }
-
- /**
- * @generated
- */
- public boolean isAffectingEvent(Object event, int flags) {
- if (event instanceof Notification) {
- return isAffectingFeature(((Notification) event).getFeature());
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean isAffectingFeature(Object feature) {
- for (int i = 0; i < features.length; i++) {
- if (features[i] == feature) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @generated
- */
- public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
- return null;
- }
-
- /**
- * @generated
- */
- protected Object[] getValues(EObject element) {
- Object[] values = new Object[features.length];
- for (int i = 0; i < features.length; i++) {
- values[i] = getValue(element, features[i]);
- }
- return values;
- }
-
- /**
- * @generated
- */
- protected Object[] getEditableValues(EObject element) {
- Object[] values = new Object[editableFeatures.length];
- for (int i = 0; i < editableFeatures.length; i++) {
- values[i] = getValue(element, editableFeatures[i]);
- }
- return values;
- }
-
- /**
- * @generated
- */
- protected Object getValue(EObject element, EAttribute feature) {
- Object value = element.eGet(feature);
- Class<?> iClass = feature.getEAttributeType().getInstanceClass();
- if (String.class.equals(iClass)) {
- if (value == null) {
- value = ""; //$NON-NLS-1$
- }
- }
- return value;
- }
-
- /**
- * @generated
- */
- protected ICommand getParseCommand(IAdaptable adapter, Object[] values, int flags) {
- if (values == null || validateNewValues(values).getCode() != IParserEditStatus.EDITABLE) {
- return UnexecutableCommand.INSTANCE;
- }
- EObject element = (EObject) adapter.getAdapter(EObject.class);
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(element);
- if (editingDomain == null) {
- return UnexecutableCommand.INSTANCE;
- }
- CompositeTransactionalCommand command = new CompositeTransactionalCommand(editingDomain, "Set Values"); //$NON-NLS-1$
- for (int i = 0; i < values.length; i++) {
- command.compose(getModificationCommand(element, editableFeatures[i], values[i]));
- }
- return command;
- }
-
- /**
- * @generated
- */
- protected ICommand getModificationCommand(EObject element, EAttribute feature, Object value) {
- value = getValidNewValue(feature, value);
- if (value instanceof InvalidValue) {
- return UnexecutableCommand.INSTANCE;
- }
- SetRequest request = new SetRequest(element, feature, value);
- return new SetValueCommand(request);
- }
-
- /**
- * @generated
- */
- protected IParserEditStatus validateNewValues(Object[] values) {
- if (values.length != editableFeatures.length) {
- return ParserEditStatus.UNEDITABLE_STATUS;
- }
- for (int i = 0; i < values.length; i++) {
- Object value = getValidNewValue(editableFeatures[i], values[i]);
- if (value instanceof InvalidValue) {
- return new ParserEditStatus(GMFToolingRuntimePlugin.ID, IParserEditStatus.UNEDITABLE, value.toString());
- }
- }
- return ParserEditStatus.EDITABLE_STATUS;
- }
-
- /**
- * @generated
- */
- protected Object getValidNewValue(EAttribute feature, Object value) {
- EClassifier type = feature.getEType();
- if (type instanceof EDataType) {
- Class<?> iClass = type.getInstanceClass();
- if (Boolean.TYPE.equals(iClass)) {
- if (value instanceof Boolean) {
- // ok
- } else if (value instanceof String) {
- value = Boolean.valueOf((String) value);
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (Character.TYPE.equals(iClass)) {
- if (value instanceof Character) {
- // ok
- } else if (value instanceof String) {
- String s = (String) value;
- if (s.length() == 0) {
- value = null;
- } else {
- value = new Character(s.charAt(0));
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (Byte.TYPE.equals(iClass)) {
- if (value instanceof Byte) {
- // ok
- } else if (value instanceof Number) {
- value = new Byte(((Number) value).byteValue());
- } else if (value instanceof String) {
- String s = (String) value;
- if (s.length() == 0) {
- value = null;
- } else {
- try {
- value = Byte.valueOf(s);
- } catch (NumberFormatException nfe) {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName()));
- }
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (Short.TYPE.equals(iClass)) {
- if (value instanceof Short) {
- // ok
- } else if (value instanceof Number) {
- value = new Short(((Number) value).shortValue());
- } else if (value instanceof String) {
- String s = (String) value;
- if (s.length() == 0) {
- value = null;
- } else {
- try {
- value = Short.valueOf(s);
- } catch (NumberFormatException nfe) {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName()));
- }
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (Integer.TYPE.equals(iClass)) {
- if (value instanceof Integer) {
- // ok
- } else if (value instanceof Number) {
- value = new Integer(((Number) value).intValue());
- } else if (value instanceof String) {
- String s = (String) value;
- if (s.length() == 0) {
- value = null;
- } else {
- try {
- value = Integer.valueOf(s);
- } catch (NumberFormatException nfe) {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName()));
- }
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (Long.TYPE.equals(iClass)) {
- if (value instanceof Long) {
- // ok
- } else if (value instanceof Number) {
- value = new Long(((Number) value).longValue());
- } else if (value instanceof String) {
- String s = (String) value;
- if (s.length() == 0) {
- value = null;
- } else {
- try {
- value = Long.valueOf(s);
- } catch (NumberFormatException nfe) {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName()));
- }
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (Float.TYPE.equals(iClass)) {
- if (value instanceof Float) {
- // ok
- } else if (value instanceof Number) {
- value = new Float(((Number) value).floatValue());
- } else if (value instanceof String) {
- String s = (String) value;
- if (s.length() == 0) {
- value = null;
- } else {
- try {
- value = Float.valueOf(s);
- } catch (NumberFormatException nfe) {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName()));
- }
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (Double.TYPE.equals(iClass)) {
- if (value instanceof Double) {
- // ok
- } else if (value instanceof Number) {
- value = new Double(((Number) value).doubleValue());
- } else if (value instanceof String) {
- String s = (String) value;
- if (s.length() == 0) {
- value = null;
- } else {
- try {
- value = Double.valueOf(s);
- } catch (NumberFormatException nfe) {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_WrongStringConversion, iClass.getName()));
- }
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, iClass.getName()));
- }
- } else if (type instanceof EEnum) {
- if (value instanceof String) {
- EEnumLiteral literal = ((EEnum) type).getEEnumLiteralByLiteral((String) value);
- if (literal == null) {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnknownLiteral, value));
- } else {
- value = literal.getInstance();
- }
- } else {
- value = new InvalidValue(NLS.bind(Messages.AbstractParser_UnexpectedValueType, String.class.getName()));
- }
- }
- }
- return value;
- }
-
- /**
- * @generated
- */
- protected class InvalidValue {
-
- /**
- * @generated
- */
- private String description;
-
- /**
- * @generated
- */
- public InvalidValue(String description) {
- this.description = description;
- }
-
- /**
- * @generated
- */
- public String toString() {
- return description;
- }
- }
-}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ChoiceParserBase.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ChoiceParserBase.java
new file mode 100644
index 000000000..3f46c981f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ChoiceParserBase.java
@@ -0,0 +1,74 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
+import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
+import org.eclipse.gmf.tooling.runtime.GMFToolingRuntimePlugin;
+import org.eclipse.gmf.tooling.runtime.directedit.ComboDirectEditManager;
+
+public abstract class ChoiceParserBase extends AbstractFeatureParser implements ComboDirectEditManager.IChoiceParser {
+ private static final int SINGLE_FEATURE_INDEX = 0;
+
+ public ChoiceParserBase(EStructuralFeature feature) {
+ super(new EStructuralFeature[] { feature });
+ }
+
+ protected final EStructuralFeature getFeature() {
+ return getEditableFeatures()[SINGLE_FEATURE_INDEX];
+ }
+
+ @Override
+ public String getEditString(IAdaptable adapter, int flags) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ return getEditChoice(element, getEditableValues(element)[SINGLE_FEATURE_INDEX]);
+ }
+
+ @Override
+ public IParserEditStatus isValidEditString(IAdaptable adapter, String editString) {
+ if (getEditChoices(adapter).contains(editString)) {
+ return ParserEditStatus.EDITABLE_STATUS;
+ }
+ return new ParserEditStatus(GMFToolingRuntimePlugin.ID, IParserEditStatus.UNEDITABLE, editString);
+ }
+
+ @Override
+ public ICommand getParseCommand(IAdaptable adapter, String newString, int flags) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ return getParseCommand(adapter, new Object[] { findItem(element, newString) }, flags);
+ }
+
+ @Override
+ public String getPrintString(IAdaptable adapter, int flags) {
+ return getEditString(adapter, flags);
+ }
+
+ @Override
+ public List<String> getEditChoices(IAdaptable adapter) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ List<String> result = new ArrayList<String>();
+ for (Object item : getItems(element)) {
+ result.add(getEditChoice(element, item));
+ }
+ return result;
+ }
+
+ private Object findItem(EObject element, String editChoice) {
+ for (Object item : getItems(element)) {
+ if (editChoice.equals(getEditChoice(element, item))) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ protected abstract Collection<Object> getItems(EObject element);
+
+ protected abstract String getEditChoice(EObject element, Object item);
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/EnumParser.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/EnumParser.java
new file mode 100644
index 000000000..a498d14f6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/EnumParser.java
@@ -0,0 +1,38 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+
+public class EnumParser extends ChoiceParserBase {
+
+ public EnumParser(EAttribute enumFeature) {
+ super(enumFeature);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Collection<Object> getItems(EObject element) {
+ List<Object> result = new ArrayList<Object>();
+ EAttribute enumFeature = (EAttribute) getFeature();
+ EEnum type = (EEnum) enumFeature.getEType();
+ @SuppressWarnings("rawtypes")
+ Class<? extends Enum> enumeratorClass = (Class<? extends Enum>) type.getInstanceClass();
+ for (EEnumLiteral eLiteral : type.getELiterals()) {
+ Object literalValue = Enum.valueOf(enumeratorClass, eLiteral.getLiteral());
+ result.add(literalValue);
+ }
+ return result;
+ }
+
+ @Override
+ protected String getEditChoice(EObject element, Object item) {
+ return ((Enum<?>) item).name();
+ }
+
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ExpressionLabelParserBase.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ExpressionLabelParserBase.java
new file mode 100644
index 000000000..d3304daa6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/ExpressionLabelParserBase.java
@@ -0,0 +1,46 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
+import org.eclipse.gmf.tooling.runtime.GMFToolingRuntimePlugin;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+
+public abstract class ExpressionLabelParserBase implements HasOclTracker, IParser {
+
+ private final OclTrackerWrapper myDelegate;
+
+ public ExpressionLabelParserBase() {
+ this(GMFToolingRuntimePlugin.getInstance().getOclTrackerFactory());
+ }
+
+ public ExpressionLabelParserBase(OclTrackerFactory.Type preferredType) {
+ this(GMFToolingRuntimePlugin.getInstance().getOclTrackerFactory(preferredType));
+ }
+
+ public ExpressionLabelParserBase(OclTrackerFactory oclTrackerFactory) {
+ myDelegate = new OclTrackerWrapper(oclTrackerFactory) {
+
+ @Override
+ protected String getExpressionBody() {
+ return ExpressionLabelParserBase.this.getExpressionBody();
+ }
+ };
+ }
+
+ @Override
+ public OclTracker getOclTracker() {
+ return myDelegate.getOclTracker();
+ }
+
+ public String getPrintString(IAdaptable element, int flags) {
+ return myDelegate.getUpdatedString(element, flags);
+ }
+
+ public boolean isAffectingEvent(Object event, int flags) {
+ return myDelegate.isAffectingEvent(event, flags);
+ }
+
+ protected abstract String getExpressionBody();
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclChoiceParser.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclChoiceParser.java
new file mode 100644
index 000000000..36a0bc6a2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclChoiceParser.java
@@ -0,0 +1,174 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.common.notify.Notification;
+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.util.QueryDelegate;
+import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker.Registrator;
+import org.eclipse.ocl.ParserException;
+import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
+import org.eclipse.ocl.ecore.OCL;
+import org.eclipse.ocl.ecore.OCL.Helper;
+import org.eclipse.ocl.ecore.OCLExpression;
+import org.eclipse.ocl.ecore.delegate.OCLQueryDelegateFactory;
+
+public class OclChoiceParser extends ChoiceParserBase {
+
+ private static final String ITEM_PARAM_NAME = "_item";
+
+ private static final String FILTER_ID = "OCLChoiceParser";
+
+ private final OCL myOcl;
+
+ private final OCLExpression myItemsOclExpression;
+
+ private final QueryDelegate myShowOclQuery;
+
+ private final AdapterFactory myAdapterFactory;
+
+ private Tracker myTracker;
+
+ public OclChoiceParser(EStructuralFeature feature, String itemsExpression, String showExpression, AdapterFactory adapterFactory) {
+ super(feature);
+
+ myAdapterFactory = adapterFactory;
+
+ myOcl = OCL.newInstance(new EcoreEnvironmentFactory());
+
+ EClass contextClass = feature.getEContainingClass();
+
+ Helper helper = myOcl.createOCLHelper();
+ helper.setContext(contextClass);
+ try {
+ myItemsOclExpression = helper.createQuery(itemsExpression);
+ } catch (ParserException e) {
+ throw new RuntimeException(e);
+ }
+
+ if (showExpression == null) {
+ myShowOclQuery = null;
+ } else {
+ Map<String, EClassifier> parameters = new HashMap<String, EClassifier>();
+ parameters.put(ITEM_PARAM_NAME, getFeature().getEType());
+ myShowOclQuery = new OCLQueryDelegateFactory().createQueryDelegate(contextClass, parameters, showExpression);
+ }
+
+ myTracker = new Tracker();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Collection<Object> getItems(EObject element) {
+ return (Collection<Object>) myOcl.evaluate(element, myItemsOclExpression);
+ }
+
+ @Override
+ protected String getEditChoice(EObject element, Object item) {
+ Object result;
+ if (item == null) {
+ result = null;
+ } else if (myShowOclQuery == null) {
+ result = item;
+ } else {
+ Map<String, Object> arguments = new HashMap<String, Object>();
+ arguments.put(ITEM_PARAM_NAME, item);
+ try {
+ result = myShowOclQuery.execute(element, arguments);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ if (result == null) {
+ return getNullItemEditChoice();
+ } else if (result instanceof EObject) {
+ EObject eResult = (EObject) result;
+ myTracker.setTracked(eResult);
+ return ((IItemLabelProvider) myAdapterFactory.adapt(eResult, IItemLabelProvider.class)).getText(eResult);
+ } else {
+ return result.toString();
+ }
+ }
+
+ protected String getNullItemEditChoice() {
+ return "";
+ }
+
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ return myTracker.isAffectingEvent(event, flags) || super.isAffectingEvent(event, flags);
+ }
+
+ public void installListeners(NotificationListener listener, Registrator oclRegistrator) {
+ myTracker.start(listener, oclRegistrator);
+ }
+
+ public void uninstallListeners() {
+ myTracker.stop();
+ }
+
+ private static class Tracker {
+
+ private Registrator myOclRegistrator;
+
+ private NotificationListener myListener;
+
+ private EObject myTracked;
+
+ private boolean myTracking = false;
+
+ public void start(NotificationListener listener, Registrator oclRegistrator) {
+ myOclRegistrator = oclRegistrator;
+ myListener = listener;
+ myTracking = true;
+ registerListener();
+ }
+
+ public void stop() {
+ unregisterListener();
+ myTracking = false;
+ }
+
+ public void setTracked(EObject tracked) {
+ if (tracked != myTracked) {
+ unregisterListener();
+ myTracked = tracked;
+ registerListener();
+ }
+ }
+
+ private void registerListener() {
+ if (!myTracking || myTracked == null) {
+ return;
+ }
+ myOclRegistrator.registerListener(FILTER_ID, myListener, myTracked);
+ }
+
+ private void unregisterListener() {
+ if (!myTracking || myTracked == null) {
+ return;
+ }
+ myOclRegistrator.unregisterListener(FILTER_ID);
+ }
+
+ public boolean isAffectingEvent(Object event, int flags) {
+ if (event instanceof Notification) {
+ Notification notification = (Notification) event;
+ if (notification.getNotifier() == myTracked) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerChoiceParser.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerChoiceParser.java
new file mode 100644
index 000000000..b7b3de252
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerChoiceParser.java
@@ -0,0 +1,61 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.tooling.runtime.GMFToolingRuntimePlugin;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+
+public class OclTrackerChoiceParser extends OclChoiceParser implements HasOclTracker {
+
+ private final OclTrackerWrapper myLabelDelegate;
+
+ public OclTrackerChoiceParser(EStructuralFeature feature, String itemsExpression, String showExpression, AdapterFactory adapterFactory) {
+ this(feature, itemsExpression, showExpression, adapterFactory, GMFToolingRuntimePlugin.getInstance().getOclTrackerFactory());
+ }
+
+ public OclTrackerChoiceParser(EStructuralFeature feature, String itemsExpression, String showExpression, AdapterFactory adapterFactory, OclTrackerFactory.Type factoryType) {
+ this(feature, itemsExpression, showExpression, adapterFactory, GMFToolingRuntimePlugin.getInstance().getOclTrackerFactory(factoryType));
+ }
+
+ public OclTrackerChoiceParser(EStructuralFeature feature, String itemsExpression, String showExpression, AdapterFactory itemProvidersAdapterFactory, OclTrackerFactory oclTrackerFactory) {
+ super(feature, itemsExpression, showExpression, itemProvidersAdapterFactory);
+
+ EClassifier featureType = feature.getEType();
+ String typeName = (feature instanceof EReference) ? featureType.getName() : featureType.getInstanceClass().getSimpleName();
+ final String labelOclExpressionText = "let _item : " + typeName + " = self." + feature.getName() + " in " + showExpression;
+
+ myLabelDelegate = new OclTrackerWrapper(oclTrackerFactory) {
+
+ @Override
+ protected String getExpressionBody() {
+ return labelOclExpressionText;
+ }
+ };
+ }
+
+ @Override
+ public String getEditString(IAdaptable adapter, int flags) {
+ EObject element = (EObject) adapter.getAdapter(EObject.class);
+ if (element != null && !getFeature().getEContainingClass().isInstance(element)) {
+ return ""; // occurs on node deletion
+ }
+ myLabelDelegate.getUpdatedString(adapter, flags);
+ return super.getEditString(adapter, flags);
+ }
+
+ @Override
+ public OclTracker getOclTracker() {
+ return myLabelDelegate.getOclTracker();
+ }
+
+ @Override
+ public boolean isAffectingEvent(Object event, int flags) {
+ return myLabelDelegate.isAffectingEvent(event, flags) || super.isAffectingEvent(event, flags);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerWrapper.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerWrapper.java
new file mode 100644
index 000000000..bb96c5d2f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/parsers/OclTrackerWrapper.java
@@ -0,0 +1,41 @@
+package org.eclipse.gmf.tooling.runtime.parsers;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+
+abstract class OclTrackerWrapper {
+
+ private final OclTrackerFactory myOclTrackerFactory;
+
+ private OclTracker myOclTracker;
+
+ public OclTrackerWrapper(OclTrackerFactory oclTrackerFactory) {
+ myOclTrackerFactory = oclTrackerFactory;
+ }
+
+ public OclTracker getOclTracker() {
+ if (myOclTracker == null) {
+ myOclTracker = myOclTrackerFactory.createOclTracker(getExpressionBody(), true);
+ }
+ return myOclTracker;
+ }
+
+ public String getUpdatedString(IAdaptable element, int flags) {
+ EObject target = (EObject) element.getAdapter(EObject.class);
+ getOclTracker().initialize(target);
+ return String.valueOf(getOclTracker().getValue());
+ }
+
+ public boolean isAffectingEvent(Object event, int flags) {
+ if (event instanceof Notification) {
+ Notification notification = (Notification) event;
+ return getOclTracker().handleNotification(notification);
+ }
+ return false;
+ }
+
+ protected abstract String getExpressionBody();
+}

Back to the top