Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgolubev2012-05-01 01:45:58 +0000
committermgolubev2012-05-01 01:45:58 +0000
commitcf14def2d6eea35c5abdafdb82930eebbaa2cb62 (patch)
tree1f479f3d0fd2a19d1dac6caa94e35371145529fe
parent61c153d1e3f15ed32d8e3ba0ff38a663caa53349 (diff)
parentf32c54db61c963ec47a687d162d476ee74efcc09 (diff)
downloadorg.eclipse.gmf-tooling-cf14def2d6eea35c5abdafdb82930eebbaa2cb62.tar.gz
org.eclipse.gmf-tooling-cf14def2d6eea35c5abdafdb82930eebbaa2cb62.tar.xz
org.eclipse.gmf-tooling-cf14def2d6eea35c5abdafdb82930eebbaa2cb62.zip
Merge branch '3.0.M7.merging-all.2.samples' into 3.0.M7-merging-all.4.372479.samples
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/.classpath8
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/.options7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/.project28
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/META-INF/MANIFEST.MF42
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/build.properties11
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/CreationEditPolicyWithCustomReparent.java131
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java19
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java33
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveViewCommand.java171
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java9
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java48
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/AbstractProportionalShape.java80
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/ShadowShape.java109
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickMan.java120
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickManWithNumber.java28
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/incomingLinksNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkSourceNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkTargetNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linksNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/obj16/TOEDiagramFile.gifbin0 -> 339 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/outgoingLinksNavigatorGroup.gifbin0 -> 709 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/wizban/NewTOEWizard.gifbin0 -> 2466 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/messages.properties84
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.properties47
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.xml566
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionCreateCommand.java153
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionReorientCommand.java158
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Department2CreateCommand.java78
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/DepartmentCreateCommand.java79
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Employee2CreateCommand.java79
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/EmployeeCreateCommand.java79
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerCreateCommand.java79
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsCreateCommand.java93
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsReorientCommand.java148
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentCreateCommand.java93
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentReorientCommand.java147
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ProjectCreateCommand.java79
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/AllHolderEditHelper.java7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ContributionEditHelper.java7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/DepartmentEditHelper.java7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/EmployeeEditHelper.java7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ManagerEditHelper.java7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ProjectEditHelper.java7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/TOEBaseEditHelper.java86
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/AllHolderEditPart.java81
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ContributionEditPart.java72
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Department2EditPart.java484
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staff2EditPart.java70
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staffEditPart.java70
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentEditPart.java484
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentName2EditPart.java534
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentNameEditPart.java534
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Employee2EditPart.java322
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeEditPart.java322
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeName2EditPart.java558
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeNameEditPart.java558
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerEditPart.java294
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerLeadsEditPart.java76
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerManagedDepartmentEditPart.java72
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerNameEditPart.java558
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectEditPart.java418
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectNameEditPart.java534
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/TOEEditPartFactory.java212
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel2EditPart.java549
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel3EditPart.java553
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel4EditPart.java553
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel5EditPart.java549
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel6EditPart.java549
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabelEditPart.java549
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderCanonicalEditPolicy.java360
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderItemSemanticEditPolicy.java68
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionConnectionPinForeground4003Policy.java56
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionItemSemanticEditPolicy.java27
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Department2ItemSemanticEditPolicy.java159
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2CanonicalEditPolicy.java172
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2ItemSemanticEditPolicy.java34
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffCanonicalEditPolicy.java172
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffItemSemanticEditPolicy.java34
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentItemSemanticEditPolicy.java159
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground2002Policy.java55
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground3002Policy.java55
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Employee2ItemSemanticEditPolicy.java103
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeeItemSemanticEditPolicy.java103
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter2001Policy.java48
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter3001Policy.java48
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible2001Policy.java48
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible3001Policy.java48
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinForeground4002Policy.java85
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinLineWidth4002Policy.java80
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerItemSemanticEditPolicy.java152
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerLeadsItemSemanticEditPolicy.java27
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerManagedDepartmentItemSemanticEditPolicy.java27
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerPinBackgroundRGB2004Policy.java54
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ProjectItemSemanticEditPolicy.java135
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/TOEBaseItemSemanticEditPolicy.java369
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/TOETextNonResizableEditPolicy.java223
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/TOETextSelectionEditPolicy.java207
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/expressions/TOEAbstractExpression.java150
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/expressions/TOEOCLFactory.java173
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOEAbstractNavigatorItem.java58
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOEDomainNavigatorContentProvider.java217
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOEDomainNavigatorItem.java106
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOEDomainNavigatorLabelProvider.java94
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOENavigatorActionProvider.java168
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOENavigatorContentProvider.java531
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOENavigatorGroup.java97
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOENavigatorItem.java84
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOENavigatorLabelProvider.java344
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOENavigatorLinkHelper.java115
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/navigator/TOENavigatorSorter.java27
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/parsers/AbstractParser.java418
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/parsers/DepartmentLabelExpressionLabelParser.java103
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/parsers/MessageFormatParser.java189
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/parsers/ProjectLabelExpressionLabelParser.java103
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/DeleteElementAction.java83
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/DiagramEditorContextMenuProvider.java66
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/LoadResourceAction.java30
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/Messages.java424
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/ModelElementSelectionPage.java140
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOECreationWizard.java154
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOECreationWizardPage.java83
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEDiagramActionBarContributor.java38
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEDiagramEditor.java271
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEDiagramEditorPlugin.java302
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEDiagramEditorUtil.java364
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEDiagramUpdateCommand.java78
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEDiagramUpdater.java539
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEDocumentProvider.java981
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEInitDiagramFileAction.java86
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOELinkDescriptor.java92
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEMatchingStrategy.java34
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOENewDiagramFileWizard.java162
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOENodeDescriptor.java42
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEPaletteFactory.java176
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEUriEditorInputTester.java22
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/part/TOEVisualIDRegistry.java314
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/preferences/DiagramAppearancePreferencePage.java17
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/preferences/DiagramConnectionsPreferencePage.java17
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/preferences/DiagramGeneralPreferencePage.java17
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/preferences/DiagramPreferenceInitializer.java31
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/preferences/DiagramPrintingPreferencePage.java17
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/preferences/DiagramRulersAndGridPreferencePage.java17
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/providers/ElementInitializers.java24
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/providers/TOEEditPartProvider.java141
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/providers/TOEElementTypes.java292
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/providers/TOEIconProvider.java31
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/providers/TOEModelingAssistantProvider.java218
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/providers/TOEParserProvider.java294
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/providers/TOEViewProvider.java634
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/sheet/TOEPropertySection.java109
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/sheet/TOESheetLabelProvider.java78
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/.classpath7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/.project28
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/META-INF/MANIFEST.MF15
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/build.properties14
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateAllHolder_all_Contribution.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateAllHolder_all_Department.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateAllHolder_all_Employee.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateAllHolder_all_Manager.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateAllHolder_all_Project.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateDepartment_employees_Employee.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateDepartment_employees_Manager.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/ctool16/CreateDepartment_subDepartments_Department.gifbin0 -> 223 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/obj16/AllHolder.gifbin0 -> 129 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/obj16/Contribution.gifbin0 -> 129 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/obj16/Department.gifbin0 -> 129 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/obj16/Employee.gifbin0 -> 129 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/obj16/Manager.gifbin0 -> 129 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/icons/full/obj16/Project.gifbin0 -> 129 bytes
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/plugin.properties52
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/plugin.xml25
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/AllBaseItemProvider.java112
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/AllHolderItemProvider.java191
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/ContributionItemProvider.java193
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/DepartmentItemProvider.java223
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/EmployeeItemProvider.java217
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/ManagerItemProvider.java162
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/ProjectItemProvider.java240
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/TOEEditPlugin.java93
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.edit/src/org/eclipse/gmf/examples/ocldriven/toe/provider/TOEItemProviderAdapterFactory.java323
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/.classpath7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/.project28
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/.settings/toe.gmfgen.prefs7
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/META-INF/MANIFEST.MF16
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/build.properties14
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.ecore57
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.emf51
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.genmodel46
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.gmfgen971
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.gmfgraph526
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.gmfmap237
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.gmftool32
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/model/toe.trace80
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/plugin.properties2
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/plugin.xml26
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/AllBase.java22
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/AllHolder.java46
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/Contribution.java111
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/Department.java158
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/Employee.java148
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/Manager.java75
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/Project.java148
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/TOEFactory.java91
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/TOEPackage.java993
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/AllBaseImpl.java45
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/AllHolderImpl.java156
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/ContributionImpl.java370
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/DepartmentImpl.java451
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/EmployeeImpl.java407
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/ManagerImpl.java261
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/ProjectImpl.java422
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/TOEFactoryImpl.java154
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/impl/TOEPackageImpl.java535
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/util/TOEAdapterFactory.java232
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/util/TOEResourceFactoryImpl.java45
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/util/TOEResourceImpl.java32
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven/src/org/eclipse/gmf/examples/ocldriven/toe/util/TOESwitch.java246
-rw-r--r--examples/org.eclipse.gmf.examples.taipan/models/taipan.emf68
218 files changed, 34203 insertions, 0 deletions
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/.classpath b/examples/org.eclipse.gmf.examples.ocldriven.diagram/.classpath
new file mode 100644
index 000000000..e63399648
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="custom-src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/.options b/examples/org.eclipse.gmf.examples.ocldriven.diagram/.options
new file mode 100644
index 000000000..3dbba03c9
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/.options
@@ -0,0 +1,7 @@
+# Tracing options for the org.eclipse.gmf.examples.ocldriven.diagram plug-in
+
+# Common issues
+org.eclipse.gmf.examples.ocldriven.diagram/debug=false
+
+# Visual IDs
+org.eclipse.gmf.examples.ocldriven.diagram/debug/visualID=false
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/.project b/examples/org.eclipse.gmf.examples.ocldriven.diagram/.project
new file mode 100644
index 000000000..d6eeea74d
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.gmf.examples.ocldriven.diagram</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/META-INF/MANIFEST.MF b/examples/org.eclipse.gmf.examples.ocldriven.diagram/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..3c70dc24b
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/META-INF/MANIFEST.MF
@@ -0,0 +1,42 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.gmf.examples.ocldriven.diagram; singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-ClassPath: .
+Bundle-Activator: org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorPlugin
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Export-Package: org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts,
+ org.eclipse.gmf.examples.ocldriven.toe.diagram.part,
+ org.eclipse.gmf.examples.ocldriven.toe.diagram.providers
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.core.expressions,
+ org.eclipse.jface,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views,
+ org.eclipse.ui.navigator,
+ org.eclipse.ui.navigator.resources,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.emf.edit.ui,
+ org.eclipse.gmf.runtime.emf.core,
+ org.eclipse.gmf.runtime.emf.commands.core,
+ org.eclipse.gmf.runtime.emf.ui.properties,
+ org.eclipse.gmf.runtime.diagram.ui,
+ org.eclipse.gmf.runtime.diagram.ui.properties,
+ org.eclipse.gmf.runtime.diagram.ui.providers,
+ org.eclipse.gmf.runtime.diagram.ui.providers.ide,
+ org.eclipse.gmf.runtime.diagram.ui.render,
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor,
+ org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide,
+ org.eclipse.gmf.tooling.runtime;visibility:=reexport,
+ org.eclipse.draw2d;visibility:=reexport,
+ org.eclipse.gmf.runtime.draw2d.ui;visibility:=reexport,
+ org.eclipse.gmf.examples.ocldriven;visibility:=reexport,
+ org.eclipse.gmf.examples.ocldriven.edit;visibility:=reexport,
+ org.eclipse.ocl.ecore;visibility:=reexport,
+ org.eclipse.gef;visibility:=reexport
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/build.properties b/examples/org.eclipse.gmf.examples.ocldriven.diagram/build.properties
new file mode 100644
index 000000000..22645ebec
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/build.properties
@@ -0,0 +1,11 @@
+bin.includes = .,\
+ icons/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties,\
+ messages.properties,\
+ .options
+jars.compile.order = .
+source.. = src/,\
+ custom-src/
+output.. = bin/
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/CreationEditPolicyWithCustomReparent.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/CreationEditPolicyWithCustomReparent.java
new file mode 100644
index 000000000..5112a77dc
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/CreationEditPolicyWithCustomReparent.java
@@ -0,0 +1,131 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.GroupEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
+import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @see #237059
+ */
+public class CreationEditPolicyWithCustomReparent extends CreationEditPolicy {
+
+ private final IVisualIDRegistry myVisualIdRegistry;
+
+ public CreationEditPolicyWithCustomReparent(IVisualIDRegistry visualIdRegistry) {
+ myVisualIdRegistry = visualIdRegistry;
+ }
+
+ @Override
+ protected Command getReparentCommand(ChangeBoundsRequest request) {
+ return super.getReparentCommand(request);
+ }
+
+ /**
+ * The only difference in this method is that we use
+ * MoveRequestWithParentInfo instead of MoveRequest and configuring it with
+ * info about actual semantic element of moved element's container
+ */
+ @Override
+ protected ICommand getReparentCommand(IGraphicalEditPart gep) {
+ CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label);
+ View container = (View) getHost().getModel();
+ EObject context = ViewUtil.resolveSemanticElement(container);
+ View view = (View) gep.getModel();
+ EObject element = ViewUtil.resolveSemanticElement(view);
+
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
+
+ //
+ // semantic
+ if (element != null) {
+ EObject actualContainer = getSemanticContainer(gep);
+ MoveRequestWithParentInfo request = new MoveRequestWithParentInfo(editingDomain, context, element);
+ request.registerActualContainer(element, actualContainer);
+ Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(request));
+
+ if (moveSemanticCmd == null) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+
+ cc.compose(new CommandProxy(moveSemanticCmd));
+ }
+ //
+ // notation
+ cc.compose(getReparentViewCommand(gep));
+ return cc;
+ }
+
+ /**
+ * The only difference in this method is that we use
+ * MoveRequestWithParentInfo instead of MoveRequest and configuring it with
+ * info about actual semantic element of moved element's container
+ */
+ protected ICommand getReparentGroupCommand(GroupEditPart groupEP) {
+ CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label);
+ View container = (View) getHost().getModel();
+ EObject context = ViewUtil.resolveSemanticElement(container);
+ EObject groupSemanticParent = getSemanticContainer(groupEP);
+
+ // semantic
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
+ for (Iterator<?> iter = groupEP.getShapeChildren().iterator(); iter.hasNext();) {
+ IGraphicalEditPart childEP = (IGraphicalEditPart) iter.next();
+ EObject element = ViewUtil.resolveSemanticElement((View) childEP.getModel());
+ if (element != null) {
+ MoveRequestWithParentInfo request = new MoveRequestWithParentInfo(editingDomain, context, element);
+ request.registerActualContainer(element, groupSemanticParent);
+ Command moveSemanticCmd = getHost().getCommand(new EditCommandRequestWrapper(request));
+
+ if (moveSemanticCmd == null) {
+ return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
+ }
+
+ cc.compose(new CommandProxy(moveSemanticCmd));
+ }
+ }
+
+ // notation
+ cc.compose(getReparentViewCommand(groupEP));
+ return cc;
+ }
+
+ protected final EObject getSemanticContainer(IGraphicalEditPart gep) {
+ IGraphicalEditPart parentEP = (IGraphicalEditPart) gep.getParent();
+ if (parentEP == null) {
+ return null;
+ }
+ View view = parentEP.getPrimaryView();
+ if (view == null) {
+ return null;
+ }
+ return ViewUtil.resolveSemanticElement(view);
+ }
+
+ @Override
+ protected ICommand getReparentViewCommand(IGraphicalEditPart gep) {
+ View container = (View) getHost().getModel();
+ View view = (View) gep.getModel();
+ MoveViewCommand result = new MoveViewCommand(gep.getEditingDomain(), new EObjectAdapter(container), new EObjectAdapter(view), getHostImpl().getDiagramPreferencesHint());
+ result.setVisualIDRegistry(myVisualIdRegistry);
+ return result;
+ }
+
+ protected final IGraphicalEditPart getHostImpl() {
+ return (IGraphicalEditPart) getHost();
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java
new file mode 100644
index 000000000..3a69f9488
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java
@@ -0,0 +1,19 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.notation.View;
+
+public interface IVisualIDRegistry {
+
+ public int getVisualID(View view);
+
+ public String getModelID(View view);
+
+ public int getNodeVisualID(View containerView, EObject domainElement);
+
+ public boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate);
+
+ public boolean isCompartmentVisualID(int visualID);
+
+ public boolean isSemanticLeafVisualID(int visualID);
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java
new file mode 100644
index 000000000..8efa10d0e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java
@@ -0,0 +1,33 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
+
+/**
+ * @see #237059
+ */
+public class MoveRequestWithParentInfo extends MoveRequest {
+
+ private final Map<EObject, EObject> myElement2ActualParent = new HashMap<EObject, EObject>();
+
+ public MoveRequestWithParentInfo(TransactionalEditingDomain editingDomain, EObject targetContainer, EObject elementToMove) {
+ super(editingDomain, targetContainer, elementToMove);
+ }
+
+ public void registerActualContainer(EObject elementToMove, EObject actualContainer) {
+ if (actualContainer != null) {
+ myElement2ActualParent.put(elementToMove, actualContainer);
+ } else {
+ myElement2ActualParent.remove(elementToMove);
+ }
+ }
+
+ public EObject getActualContainer(EObject movedElement) {
+ return myElement2ActualParent.get(movedElement);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveViewCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveViewCommand.java
new file mode 100644
index 000000000..e01622caf
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveViewCommand.java
@@ -0,0 +1,171 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+
+public class MoveViewCommand extends AbstractTransactionalCommand {
+
+ private final IAdaptable myParent;
+
+ private final IAdaptable myChild;
+
+ private final int myIndex;
+
+ private final PreferencesHint myPreferences;
+
+ private IVisualIDRegistry myVisualIDRegistry;
+
+ public MoveViewCommand(TransactionalEditingDomain editingDomain, IAdaptable parent, IAdaptable child, PreferencesHint preferencesHint) {
+ this(editingDomain, parent, child, ViewUtil.APPEND, preferencesHint);
+ }
+
+ public MoveViewCommand(TransactionalEditingDomain editingDomain, IAdaptable parent, IAdaptable child, int index, PreferencesHint preferences) {
+ super(editingDomain, "Move view", null);
+ myParent = parent;
+ myChild = child;
+ myIndex = index;
+ myPreferences = preferences;
+ }
+
+ public void setVisualIDRegistry(IVisualIDRegistry visualIDRegistry) {
+ myVisualIDRegistry = visualIDRegistry;
+ }
+
+ public List<?> getAffectedFiles() {
+ View view = (View) myParent.getAdapter(View.class);
+ if (view != null) {
+ List<IFile> result = new ArrayList<IFile>();
+ IFile file = WorkspaceSynchronizer.getFile(view.eResource());
+
+ if (file != null) {
+ result.add(file);
+ }
+ return result;
+ }
+ return super.getAffectedFiles();
+ }
+
+ protected boolean checkCanMoveView(View parentView, View childView, EObject child) {
+ if (myVisualIDRegistry == null) {
+ return false;
+ }
+ int actualVisualId = myVisualIDRegistry.getVisualID(childView);
+ return myVisualIDRegistry.checkNodeVisualID(parentView, child, actualVisualId);
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ View parentView = (View) myParent.getAdapter(View.class);
+ View childView = (View) myChild.getAdapter(View.class);
+ EObject child = childView.getElement();
+ if (child instanceof Edge) {
+ justMoveActualView(parentView, childView);
+ return CommandResult.newOKCommandResult();
+ }
+
+ if (checkCanMoveView(parentView, childView, child)) {
+ justMoveActualView(parentView, childView);
+ } else {
+ createNewView(parentView, childView, child);
+ }
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * Just a hook, default implementation does nothing
+ */
+ protected void importStyles(View newView, View childView) {
+ //
+ }
+
+ protected View basicCreateNewView(View parentView, View childView, EObject child) {
+ IAdaptable semanticAdapter = new EObjectAdapter(child);
+ String semanticHint = null;
+ View result = ViewService.getInstance().createView(
+ //
+ Node.class, semanticAdapter, parentView, semanticHint, myIndex, true, myPreferences);
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected View createNewView(View parentView, View oldChildView, EObject child) {
+ // unfortunately, we have to reuse childView instance in order to allow
+ // command from layout edit policy to set correct bounds
+ // in order to do this, we will create the new view using service and
+ // then copy all its meaningfull contents
+ // into the original view instance
+ View newView = basicCreateNewView(parentView, oldChildView, child);
+ if (newView == null) {
+ return null;
+ }
+ removeViewFromContainer(newView);
+ justMoveActualView(parentView, oldChildView);
+
+ List<View> edgesToAndFromHierarchy = collectChildrenLinks(oldChildView, new ArrayList<View>());
+
+ oldChildView.getPersistedChildren().clear();
+ oldChildView.getTransientChildren().clear();
+ oldChildView.getSourceEdges().clear();
+ oldChildView.getTargetEdges().clear();
+
+ for (View childView : edgesToAndFromHierarchy) {
+ ViewUtil.destroy(childView);
+ }
+
+ oldChildView.getStyles().clear();
+
+ oldChildView.getStyles().addAll(newView.getStyles());
+ oldChildView.getPersistedChildren().addAll(newView.getPersistedChildren());
+ oldChildView.getTransientChildren().addAll(newView.getTransientChildren());
+ oldChildView.getSourceEdges().addAll(newView.getSourceEdges());
+ oldChildView.getTargetEdges().addAll(newView.getTargetEdges());
+
+ oldChildView.setType(newView.getType());
+
+ return oldChildView;
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<View> collectChildrenLinks(View view, List<View> output) {
+ output.addAll(view.getTargetEdges());
+ output.addAll(view.getSourceEdges());
+ for (Object child : view.getChildren()) {
+ if (child instanceof View) {
+ collectChildrenLinks((View) child, output);
+ }
+ }
+ return output;
+ }
+
+ private void justMoveActualView(View parentView, View childView) {
+ if (myIndex == ViewUtil.APPEND) {
+ parentView.insertChild(childView);
+ } else {
+ parentView.insertChildAt(childView, myIndex);
+ }
+ }
+
+ private void removeViewFromContainer(View view) {
+ if (view.eContainer() instanceof View) {
+ ((View) view.eContainer()).removeChild(view);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java
new file mode 100644
index 000000000..db4c76f8b
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+
+public class TOECreationEditPolicyWithCustomReparent extends CreationEditPolicyWithCustomReparent {
+
+ public TOECreationEditPolicyWithCustomReparent() {
+ super(new TOEVisualIDRegistryImpl());
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java
new file mode 100644
index 000000000..49d27135e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java
@@ -0,0 +1,48 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentDepartment_staff2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentDepartment_staffEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.runtime.notation.View;
+
+public class TOEVisualIDRegistryImpl implements IVisualIDRegistry {
+
+ @Override
+ public int getVisualID(View view) {
+ return TOEVisualIDRegistry.getVisualID(view);
+ }
+
+ @Override
+ public String getModelID(View view) {
+ return TOEVisualIDRegistry.getModelID(view);
+ }
+
+ @Override
+ public int getNodeVisualID(View containerView, EObject domainElement) {
+ return TOEVisualIDRegistry.getNodeVisualID(containerView, domainElement);
+ }
+
+ @Override
+ public boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
+ return getNodeVisualID(containerView, domainElement) == candidate;
+ }
+
+ @Override
+ public boolean isCompartmentVisualID(int visualID) {
+ switch (visualID) {
+ case DepartmentDepartment_staff2EditPart.VISUAL_ID:
+ case DepartmentDepartment_staffEditPart.VISUAL_ID:
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ public boolean isSemanticLeafVisualID(int visualID) {
+ return false;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/AbstractProportionalShape.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/AbstractProportionalShape.java
new file mode 100644
index 000000000..eba4caba8
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/AbstractProportionalShape.java
@@ -0,0 +1,80 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.figures;
+
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+public abstract class AbstractProportionalShape extends Shape {
+
+ public AbstractProportionalShape() {
+ }
+
+ protected void setW2HRatio(float w2hRatio) {
+ myW2HRatio = w2hRatio;
+ myIsKeepingProportions = true;
+ }
+
+ protected void setKeepingProportions(boolean newValue) {
+ myIsKeepingProportions = newValue;
+ }
+
+ protected boolean isKeepingProportions() {
+ return myIsKeepingProportions;
+ }
+
+ /**
+ * If keeping proportions, returns the maximum rectangle that is fully
+ * inside the bounds and has the specified proportions. Otherwise, returns
+ * the bounds.
+ */
+ public Rectangle getProportionalBounds() {
+ Rectangle area = getClientArea();
+ if (!myIsKeepingProportions || myW2HRatio == 0.0f || area.height == 0) {
+ return new Rectangle(area);
+ }
+
+ int newX = area.x;
+ int newY = area.y;
+ int newW = area.width;
+ int newH = area.height;
+
+ float currentRatio = ((float) newW) / ((float) newH);
+ float discrepancy = currentRatio / myW2HRatio;
+
+ if (discrepancy < 1) {
+ // we are too high.
+ newH = Math.round(newH * discrepancy);
+ newY += (area.height - newH) / 2;
+ } else {
+ // we are too wide
+ newW = Math.round(newW / discrepancy);
+ newX += (area.width - newW) / 2;
+ }
+ return new Rectangle(newX, newY, newW, newH);
+ }
+
+ /**
+ * If keeping proportions, returns the dimension tweaked by the same factor
+ * as the proportional bounds relate to the original bounds. Otherwise,
+ * returns the original dimension.
+ */
+ public Dimension adjustDimension(Dimension d) {
+ Rectangle area = getClientArea();
+ if (!myIsKeepingProportions || myW2HRatio == 0.0f || area.height == 0) {
+ return new Dimension(d);
+ }
+
+ float currentRatio = ((float) area.width) / ((float) area.height);
+ float discrepancy = currentRatio / myW2HRatio;
+
+ if (discrepancy < 1) {
+ return new Dimension(d.width, (int) (d.height * discrepancy));
+ } else {
+ return new Dimension((int) (d.width / discrepancy), d.height);
+ }
+ }
+
+ private float myW2HRatio = 1.0f;
+
+ private boolean myIsKeepingProportions;
+} \ No newline at end of file
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/ShadowShape.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/ShadowShape.java
new file mode 100644
index 000000000..80e6bb3a9
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/ShadowShape.java
@@ -0,0 +1,109 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.figures;
+
+import org.eclipse.draw2d.AbstractBorder;
+import org.eclipse.draw2d.Border;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public abstract class ShadowShape extends AbstractProportionalShape {
+
+ private static final Color SHADOW_COLOR = new Color(null, 150, 150, 150);
+
+ private static final int SHADOW_SIZE = 3;
+
+ private static final Insets SHADOW_INSETS = new Insets(0, 0, SHADOW_SIZE, SHADOW_SIZE);
+
+ public ShadowShape(boolean is3D, Color backgroundColor, Color foregroundColor) {
+ setForegroundColor(foregroundColor);
+ setBackgroundColor(backgroundColor);
+ myBorder = new ShadowBorder();
+ setBorder(myBorder);
+ set3D(is3D);
+ }
+
+ protected boolean is3D() {
+ return my3D;
+ }
+
+ public void set3D(boolean is3D) {
+ if (my3D == is3D) {
+ return;
+ }
+ my3D = is3D;
+ repaint();
+ }
+
+ public Dimension getPreferredSize(int wHint, int hHint) {
+ Dimension original = super.getPreferredSize(wHint, hHint);
+ if (is3D()) {
+ original.expand(SHADOW_SIZE, SHADOW_SIZE);
+ }
+ return original;
+ }
+
+ /**
+ * Paints this figure, including its border and children. Border is painted
+ * first.
+ */
+ public void paint(Graphics graphics) {
+ paintBorder(graphics);
+ if (getBackgroundColor() != null)
+ graphics.setBackgroundColor(getBackgroundColor());
+ if (getForegroundColor() != null)
+ graphics.setForegroundColor(getForegroundColor());
+ if (getFont() != null)
+ graphics.setFont(getFont());
+ paintFigure(graphics);
+ paintClientArea(graphics);
+ }
+
+ protected void fillShape(Graphics graphics) {
+ fillShape(graphics, getProportionalBounds());
+ }
+
+ protected abstract void fillShape(Graphics graphics, Rectangle bounds);
+
+ protected void outlineShape(Graphics graphics) {
+ outlineShape(graphics, getProportionalBounds());
+ }
+
+ protected abstract void outlineShape(Graphics graphics, Rectangle bounds);
+
+ private class ShadowBorder extends AbstractBorder {
+
+ public Insets getInsets(IFigure figure) {
+ return is3D() ? SHADOW_INSETS : IFigure.NO_INSETS;
+ }
+
+ public boolean isOpaque() {
+ return is3D();
+ }
+
+ public void paint(IFigure figure, Graphics graphics, Insets insets) {
+ if (!is3D()) {
+ return;
+ }
+ graphics.setBackgroundColor(SHADOW_COLOR);
+ Rectangle rec = getProportionalBounds().getTranslated(SHADOW_SIZE, SHADOW_SIZE);
+ graphics.pushState();
+ graphics.clipRect(rec);
+ // graphics.setClip(new Rectangle(rec.x, rec.y + rec.height -
+ // getShift(), rec.width, getShift()));
+ fillShape(graphics, rec);
+ graphics.popState();
+ // graphics.setClip(new Rectangle(rec.x + rec.width - getShift(),
+ // rec.y, getShift(), rec.height));
+ // fillShape(graphics, rec);
+ }
+
+ }
+
+ private boolean my3D;
+
+ private Border myBorder;
+
+} \ No newline at end of file
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickMan.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickMan.java
new file mode 100644
index 000000000..fabfd2935
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickMan.java
@@ -0,0 +1,120 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.figures;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class StickMan extends ShadowShape {
+
+ public StickMan() {
+ this(false, ColorConstants.white, ColorConstants.black);
+ }
+
+ public StickMan(boolean is3D, Color backgroundColor, Color foregroundColor) {
+ super(is3D, backgroundColor, foregroundColor);
+ setKeepingProportions(true);
+ setW2HRatio(BASE_W / BASE_H);
+ setLayoutManager(new StackLayout());
+ }
+
+ protected void outlineShape(Graphics graphics, Rectangle bounds) {
+ PointList pl = setupPoints(bounds);
+ graphics.drawPolygon(pl);
+ int add = graphics.getLineWidth() / 2;
+ graphics.drawOval(new Rectangle(ovalX, ovalY, ovalD + add, ovalD + add));
+ }
+
+ protected void fillShape(Graphics graphics, Rectangle bounds) {
+ PointList pl = setupPoints(bounds);
+ graphics.fillPolygon(pl);
+ int add = graphics.getLineWidth() / 2;
+ graphics.fillOval(new Rectangle(ovalX, ovalY, ovalD + add, ovalD + add));
+ }
+
+ protected PointList setupPoints(Rectangle rect) {
+ int[] xPoints = new int[P_NUM];
+ int[] yPoints = new int[P_NUM];
+
+ PointList pl = new PointList(10);
+ int W = (rect.width / 2) * 2;
+ int H = rect.height;
+ int X1 = W / 2;
+ int Y1 = (Math.round(H * FACTOR1) / 2) * 2;
+ int Y2 = Math.round(H * FACTOR2);
+ int Y3 = H - (X1 - 1);
+ int STEP = Math.round(W / BASE_W);
+ if (STEP < 1) {
+ STEP = 1;
+ }
+
+ // set positive points. (0...9)
+ xPoints[0] = STEP;
+ yPoints[0] = Y1;
+ xPoints[1] = STEP;
+ yPoints[1] = Y2 - STEP;
+ xPoints[2] = X1;
+ yPoints[2] = Y2 - STEP;
+ xPoints[3] = X1;
+ yPoints[3] = Y2 + STEP;
+ xPoints[4] = STEP;
+ yPoints[4] = Y2 + STEP;
+ xPoints[5] = STEP;
+ yPoints[5] = Y3 - STEP;
+ xPoints[6] = X1;
+ yPoints[6] = H - STEP;
+ xPoints[7] = X1;
+ yPoints[7] = H;
+ xPoints[8] = X1 - 2 * STEP;
+ yPoints[8] = H;
+ xPoints[9] = 0;
+ yPoints[9] = Y3 + STEP;
+
+ // reflect points 0..8
+ for (int i = 0; i <= 8; i++) {
+ xPoints[18 - i] = -xPoints[i];
+ yPoints[18 - i] = yPoints[i];
+ }
+
+ // close polyline.
+ xPoints[19] = xPoints[0];
+ yPoints[19] = yPoints[0];
+
+ // shift all points and copy to integer.
+ for (int i = 0; i < P_NUM; i++) {
+ xPoints[i] += X1;
+
+ xPoints[i] += rect.x;
+ yPoints[i] += rect.y;
+ }
+
+ for (int i = 0; i < xPoints.length; i++) {
+ pl.addPoint(xPoints[i], yPoints[i]);
+ }
+
+ // head-oval
+ ovalD = Y1;
+ ovalX = X1 - ovalD / 2 + rect.x;
+ ovalY = rect.y;
+
+ return pl;
+ }
+
+ private static final float BASE_W = 31 - 1;
+
+ private static final float BASE_H = 50 - 1;
+
+ private static final float FACTOR1 = 16f / BASE_H;
+
+ private static final float FACTOR2 = 22f / BASE_H;
+
+ private static final int P_NUM = 20;
+
+ private int ovalX;
+
+ private int ovalY;
+
+ private int ovalD;
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickManWithNumber.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickManWithNumber.java
new file mode 100644
index 000000000..910ead5af
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/figures/StickManWithNumber.java
@@ -0,0 +1,28 @@
+package org.eclipse.gmf.examples.ocldriven.diagram.figures;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class StickManWithNumber extends StickMan {
+
+ private int myCounter;
+
+ public void setCounter(int counter) {
+ myCounter = counter;
+ }
+
+ @Override
+ protected void outlineShape(Graphics graphics, Rectangle bounds) {
+ super.outlineShape(graphics, bounds);
+ graphics.drawText(String.valueOf(myCounter), bounds.getLocation());
+ }
+
+ public void setForegroundColorRGB(Integer red, Integer green, Integer blue) {
+ setForegroundColor(new Color(null, red, green, blue));
+ }
+
+ public void setBackgroundRGB(Integer red, Integer green, Integer blue) {
+ setBackgroundColor(new Color(null, red, green, blue));
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/incomingLinksNavigatorGroup.gif b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/incomingLinksNavigatorGroup.gif
new file mode 100644
index 000000000..fca9c53e6
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/incomingLinksNavigatorGroup.gif
Binary files differ
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkSourceNavigatorGroup.gif b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkSourceNavigatorGroup.gif
new file mode 100644
index 000000000..fca9c53e6
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkSourceNavigatorGroup.gif
Binary files differ
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkTargetNavigatorGroup.gif b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkTargetNavigatorGroup.gif
new file mode 100644
index 000000000..fca9c53e6
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linkTargetNavigatorGroup.gif
Binary files differ
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linksNavigatorGroup.gif b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linksNavigatorGroup.gif
new file mode 100644
index 000000000..fca9c53e6
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/linksNavigatorGroup.gif
Binary files differ
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/obj16/TOEDiagramFile.gif b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/obj16/TOEDiagramFile.gif
new file mode 100644
index 000000000..a09c490d6
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/obj16/TOEDiagramFile.gif
Binary files differ
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/outgoingLinksNavigatorGroup.gif b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/outgoingLinksNavigatorGroup.gif
new file mode 100644
index 000000000..fca9c53e6
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/outgoingLinksNavigatorGroup.gif
Binary files differ
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/wizban/NewTOEWizard.gif b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/wizban/NewTOEWizard.gif
new file mode 100644
index 000000000..7f02760b5
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/icons/wizban/NewTOEWizard.gif
Binary files differ
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/messages.properties b/examples/org.eclipse.gmf.examples.ocldriven.diagram/messages.properties
new file mode 100644
index 000000000..f8decb348
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/messages.properties
@@ -0,0 +1,84 @@
+
+# TODO: manually put keys and values
+TOECreationWizardTitle=New TOE Diagram
+TOECreationWizard_DiagramModelFilePageTitle=Create TOE Diagram
+TOECreationWizard_DiagramModelFilePageDescription=Select file that will contain diagram model.
+TOECreationWizard_DomainModelFilePageTitle=Create TOE Domain Model
+TOECreationWizard_DomainModelFilePageDescription=Select file that will contain domain model.
+TOECreationWizardOpenEditorError=Error opening diagram editor
+TOECreationWizardCreationError=Creation Problems
+TOECreationWizardPageExtensionError=File name should have {0} extension.
+TOEDiagramEditorUtil_OpenModelResourceErrorDialogTitle=Error
+TOEDiagramEditorUtil_OpenModelResourceErrorDialogMessage=Failed to load model file {0}
+TOEDiagramEditorUtil_CreateDiagramProgressTask=Creating diagram and model files
+TOEDiagramEditorUtil_CreateDiagramCommandLabel=Creating diagram and model
+TOEDocumentProvider_isModifiable=Updating cache failed
+TOEDocumentProvider_handleElementContentChanged=Failed to refresh hierarchy for changed resource
+TOEDocumentProvider_IncorrectInputError={1}
+TOEDocumentProvider_NoDiagramInResourceError=Diagram is not present in resource
+TOEDocumentProvider_DiagramLoadingError=Error loading diagram
+TOEDocumentProvider_UnsynchronizedFileSaveError=The file has been changed on the file system
+TOEDocumentProvider_SaveDiagramTask=Saving diagram
+TOEDocumentProvider_SaveNextResourceTask=Saving {0}
+TOEDocumentProvider_SaveAsOperation=Saving {0} diagram as
+InitDiagramFile_ResourceErrorDialogTitle=Error
+InitDiagramFile_ResourceErrorDialogMessage=Model file loading failed
+InitDiagramFile_WizardTitle=Initialize new {0} diagram file
+InitDiagramFile_OpenModelFileDialogTitle=Select domain model
+TOENewDiagramFileWizard_CreationPageName=Initialize new diagram file
+TOENewDiagramFileWizard_CreationPageTitle=Diagram file
+TOENewDiagramFileWizard_CreationPageDescription=Create new diagram based on {0} model content
+TOENewDiagramFileWizard_RootSelectionPageName=Select diagram root element
+TOENewDiagramFileWizard_RootSelectionPageTitle=Diagram root element
+TOENewDiagramFileWizard_RootSelectionPageDescription=Select semantic model element to be depicted on diagram
+TOENewDiagramFileWizard_RootSelectionPageSelectionTitle=Select diagram root element:
+TOENewDiagramFileWizard_RootSelectionPageNoSelectionMessage=Diagram root element is not selected
+TOENewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage=Invalid diagram root element is selected
+TOENewDiagramFileWizard_InitDiagramCommand=Initializing diagram contents
+TOENewDiagramFileWizard_IncorrectRootError=Incorrect model object stored as a root resource object
+TOEDiagramEditor_SavingDeletedFile=The original file "{0}" has been deleted.
+TOEDiagramEditor_SaveAsErrorTitle=Problem During Save As...
+TOEDiagramEditor_SaveAsErrorMessage=Save could not be completed. Target file is already open in another editor.
+TOEDiagramEditor_SaveErrorTitle=Save Problems
+TOEDiagramEditor_SaveErrorMessage=Could not save file.
+TOEElementChooserDialog_SelectModelElementTitle=Select model element
+ModelElementSelectionPageMessage=Select model element:
+ValidateActionMessage=Validate
+Default1Group_title=Default
+Default1Group_desc=Holds top-level non-container tools
+Employee1CreationTool_title=Employee
+Employee1CreationTool_desc=Employee
+Department2CreationTool_title=Department
+Project3CreationTool_title=Project
+Project3CreationTool_desc=Project
+Manager4CreationTool_title=Manager
+Manager4CreationTool_desc=Manager
+ManagersLink5CreationTool_title=Manager's Link
+ManagersLink5CreationTool_desc=Manages the Department or Leads the Project
+Contribution6CreationTool_title=Contribution
+Contribution6CreationTool_desc=Contribution of an employee to a project
+DepartmentDepartment_staffEditPart_title=Department_staff
+DepartmentDepartment_staff2EditPart_title=Department_staff
+
+CommandName_OpenDiagram=Open Diagram
+NavigatorGroupName_Department_2002_incominglinks=incoming links
+NavigatorGroupName_Employee_3001_outgoinglinks=outgoing links
+NavigatorGroupName_Department_3002_incominglinks=incoming links
+NavigatorGroupName_Project_2003_incominglinks=incoming links
+NavigatorGroupName_ManagerLeads_4002_target=target
+NavigatorGroupName_ManagerLeads_4002_source=source
+NavigatorGroupName_Contribution_4003_target=target
+NavigatorGroupName_Contribution_4003_source=source
+NavigatorGroupName_AllHolder_1000_links=links
+NavigatorGroupName_Manager_2004_outgoinglinks=outgoing links
+NavigatorGroupName_ManagerManagedDepartment_4001_target=target
+NavigatorGroupName_ManagerManagedDepartment_4001_source=source
+NavigatorGroupName_Employee_2001_outgoinglinks=outgoing links
+NavigatorActionProvider_OpenDiagramActionName=Open Diagram
+AbstractParser_UnexpectedValueType=Value of type {0} is expected
+AbstractParser_WrongStringConversion=String value does not convert to {0} value
+AbstractParser_UnknownLiteral=Unknown literal: {0}
+
+MessageFormatParser_InvalidInputError=Invalid input at {0}
+TOEModelingAssistantProviderTitle=Select domain model element
+TOEModelingAssistantProviderMessage=Available domain model elements:
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.properties b/examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.properties
new file mode 100644
index 000000000..05791ddcf
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.properties
@@ -0,0 +1,47 @@
+pluginName=TOE Plugin
+providerName=Sample Plugin Provider, Inc
+
+editorName=TOE Diagram Editing
+context.description=TOE Diagram Editing
+context.name=In TOE Diagram Editor
+newWizardName=TOE Diagram
+newWizardDesc=Creates TOE diagram.
+
+initDiagramActionLabel=Initialize toe_diagram diagram file
+
+
+navigatorContentName=*.toe_diagram diagram contents
+domainNavigatorContentName=*.toe model contents
+update.diagram.name=Update TOE diagram
+update.diagram.description=Perform TOE diagram update
+
+
+# Property Sheet
+tab.appearance=Appearance
+tab.diagram=Rulers & Grid
+tab.domain=Core
+
+# Preferences
+prefpage.org.eclipse.gmf.examples.ocldriven.diagram.general=TOE Diagram
+prefpage.org.eclipse.gmf.examples.ocldriven.diagram.appearance=Appearance
+prefpage.org.eclipse.gmf.examples.ocldriven.diagram.connections=Connections
+prefpage.org.eclipse.gmf.examples.ocldriven.diagram.printing=Printing
+prefpage.org.eclipse.gmf.examples.ocldriven.diagram.rulersAndGrid=Rulers And Grid
+
+
+# Providers
+metatype.name.AllHolder_1000=Undefined
+metatype.name.Employee_2001=Employee
+metatype.name.Department_2002=Department
+metatype.name.Project_2003=Project
+metatype.name.Manager_2004=Manager
+metatype.name.Employee_3001=Employee
+metatype.name.Department_3002=Department
+metatype.name.ManagerManagedDepartment_4001=Undefined
+metatype.name.ManagerLeads_4002=Undefined
+metatype.name.Contribution_4003=Contribution
+
+# Commands and menu actions
+cmdcategory.name=TOE Editor Commands
+cmdcategory.desc=TOE Editor Commands
+
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.xml b/examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.xml
new file mode 100644
index 000000000..375ca156d
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/plugin.xml
@@ -0,0 +1,566 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+ <extension point="org.eclipse.team.core.fileTypes" id="repo-ftype">
+ <?gmfgen generated="true"?>
+ <fileTypes type="text" extension="toed"/>
+ </extension>
+
+ <extension point="org.eclipse.emf.ecore.extension_parser" id="resource-factory">
+ <?gmfgen generated="true"?>
+ <parser
+ type="toed"
+ class="org.eclipse.gmf.runtime.emf.core.resources.GMFResourceFactory">
+ </parser>
+ </extension>
+
+ <extension point="org.eclipse.ui.editors" id="gmf-editor">
+ <?gmfgen generated="true"?>
+ <editor
+ id="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorID"
+ name="%editorName"
+ icon="icons/obj16/TOEDiagramFile.gif"
+ extensions="toed"
+ default="true"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditor"
+ matchingStrategy="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEMatchingStrategy"
+ contributorClass="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramActionBarContributor">
+ </editor>
+ </extension>
+
+ <extension point="org.eclipse.ui.contexts" id="ui-context">
+ <?gmfgen generated="true"?>
+ <context
+ description="%context.description"
+ id="org.eclipse.gmf.examples.ocldriven.toe.diagram.ui.diagramContext"
+ name="%context.name"
+ parentId="org.eclipse.gmf.runtime.diagram.ui.diagramContext">
+ </context>
+ </extension>
+
+ <extension point="org.eclipse.ui.newWizards" id="creation-wizard">
+ <?gmfgen generated="true"?>
+ <wizard
+ name="%newWizardName"
+ icon="icons/obj16/TOEDiagramFile.gif"
+ category="org.eclipse.ui.Examples"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOECreationWizard"
+ id="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOECreationWizardID">
+ <description>%newWizardDesc</description>
+ </wizard>
+ </extension>
+
+ <extension point="org.eclipse.ui.popupMenus" id="init-diagram-action">
+ <?gmfgen generated="true"?>
+ <objectContribution
+ id="org.eclipse.gmf.examples.ocldriven.diagram.InitDiagram"
+ nameFilter="*.toe"
+ objectClass="org.eclipse.core.resources.IFile">
+ <action
+ label="%initDiagramActionLabel"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEInitDiagramFileAction"
+ menubarPath="additions"
+ enablesFor="1"
+ id="org.eclipse.gmf.examples.ocldriven.diagram.InitDiagramAction">
+ </action>
+ </objectContribution>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.common.ui.services.action.globalActionHandlerProviders" id="global-actions">
+ <?gmfgen generated="true"?>
+ <GlobalActionHandlerProvider
+ class="org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandlerProvider"
+ id="TOEPresentation">
+ <Priority name="Lowest"/>
+ <ViewId id="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorID">
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ <GlobalActionId actionId="delete"/>
+ </ElementType>
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart">
+ <GlobalActionId actionId="save"/>
+ </ElementType>
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ <GlobalActionId actionId="save">
+ </GlobalActionId>
+ </ElementType>
+ </ViewId>
+ </GlobalActionHandlerProvider>
+ <GlobalActionHandlerProvider
+ class="org.eclipse.gmf.runtime.diagram.ui.providers.ide.providers.DiagramIDEGlobalActionHandlerProvider"
+ id="TOEPresentationIDE">
+ <Priority name="Lowest"/>
+ <ViewId id="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorID">
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ <GlobalActionId actionId="bookmark"/>
+ </ElementType>
+ </ViewId>
+ </GlobalActionHandlerProvider>
+ <GlobalActionHandlerProvider
+ class="org.eclipse.gmf.runtime.diagram.ui.render.providers.DiagramUIRenderGlobalActionHandlerProvider"
+ id="TOERender">
+ <Priority name="Lowest"/>
+ <ViewId id="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorID">
+ <ElementType class="org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart">
+ <GlobalActionId actionId="cut"/>
+ <GlobalActionId actionId="copy"/>
+ <GlobalActionId actionId="paste"/>
+ </ElementType>
+ </ViewId>
+ </GlobalActionHandlerProvider>
+ </extension>
+
+
+ <extension point="org.eclipse.core.runtime.preferences" id="prefs">
+ <?gmfgen generated="true"?>
+ <initializer class="org.eclipse.gmf.examples.ocldriven.toe.diagram.preferences.DiagramPreferenceInitializer"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.preferencePages" id="prefpages">
+ <?gmfgen generated="true"?>
+ <page
+ id="org.eclipse.gmf.examples.ocldriven.diagram.general"
+ name="%prefpage.org.eclipse.gmf.examples.ocldriven.diagram.general"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.preferences.DiagramGeneralPreferencePage">
+ </page>
+ <page
+ id="org.eclipse.gmf.examples.ocldriven.diagram.appearance"
+ name="%prefpage.org.eclipse.gmf.examples.ocldriven.diagram.appearance"
+ category="org.eclipse.gmf.examples.ocldriven.diagram.general"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.preferences.DiagramAppearancePreferencePage">
+ </page>
+ <page
+ id="org.eclipse.gmf.examples.ocldriven.diagram.connections"
+ name="%prefpage.org.eclipse.gmf.examples.ocldriven.diagram.connections"
+ category="org.eclipse.gmf.examples.ocldriven.diagram.general"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.preferences.DiagramConnectionsPreferencePage">
+ </page>
+ <page
+ id="org.eclipse.gmf.examples.ocldriven.diagram.printing"
+ name="%prefpage.org.eclipse.gmf.examples.ocldriven.diagram.printing"
+ category="org.eclipse.gmf.examples.ocldriven.diagram.general"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.preferences.DiagramPrintingPreferencePage">
+ </page>
+ <page
+ id="org.eclipse.gmf.examples.ocldriven.diagram.rulersAndGrid"
+ name="%prefpage.org.eclipse.gmf.examples.ocldriven.diagram.rulersAndGrid"
+ category="org.eclipse.gmf.examples.ocldriven.diagram.general"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.preferences.DiagramRulersAndGridPreferencePage">
+ </page>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor" id="prop-contrib">
+ <?gmfgen generated="true"?>
+ <propertyContributor
+ contributorId="org.eclipse.gmf.examples.ocldriven.diagram"
+ labelProvider="org.eclipse.gmf.examples.ocldriven.toe.diagram.sheet.TOESheetLabelProvider">
+ <propertyCategory category="domain"/>
+ <propertyCategory category="visual"/>
+ <propertyCategory category="extra"/>
+ </propertyContributor>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs" id="proptabs">
+ <?gmfgen generated="true"?>
+ <propertyTabs contributorId="org.eclipse.gmf.examples.ocldriven.diagram">
+ <propertyTab
+ category="visual"
+ id="property.tab.AppearancePropertySection"
+ label="%tab.appearance"/>
+ <propertyTab
+ category="visual"
+ id="property.tab.DiagramPropertySection"
+ label="%tab.diagram"/>
+ <propertyTab
+ category="domain"
+ id="property.tab.domain"
+ label="%tab.domain"/>
+ </propertyTabs>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections" id="propsections">
+ <?gmfgen generated="true"?>
+ <propertySections contributorId="org.eclipse.gmf.examples.ocldriven.diagram">
+ <propertySection id="property.section.ConnectorAppearancePropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.ConnectionEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ConnectionAppearancePropertySection"
+ tab="property.tab.AppearancePropertySection">
+ </propertySection>
+ <propertySection id="property.section.ShapeColorAndFontPropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.ShapeEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.ShapeColorsAndFontsPropertySection"
+ tab="property.tab.AppearancePropertySection">
+ </propertySection>
+ <propertySection id="property.section.DiagramColorsAndFontsPropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.DiagramEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.appearance.DiagramColorsAndFontsPropertySection"
+ tab="property.tab.AppearancePropertySection">
+ </propertySection>
+ <propertySection id="property.section.RulerGridPropertySection"
+ filter="org.eclipse.gmf.runtime.diagram.ui.properties.filters.DiagramEditPartPropertySectionFilter"
+ class="org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid.RulerGridPropertySection"
+ tab="property.tab.DiagramPropertySection">
+ </propertySection>
+ <propertySection
+ id="property.section.domain"
+ tab="property.tab.domain"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.sheet.TOEPropertySection">
+ <input type="org.eclipse.gmf.runtime.notation.View"/>
+ <input type="org.eclipse.gef.EditPart"/>
+ <input type="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEAbstractNavigatorItem"/>
+ </propertySection>
+ </propertySections>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.diagram.core.viewProviders" id="view-provider">
+ <?gmfgen generated="true"?>
+ <viewProvider class="org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEViewProvider">
+ <Priority name="Lowest"/>
+ <context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="TOE"/>
+ <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="2001,2002,2003,2004,3001,3002"/>
+ <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="4001,4002,4003"/>
+ </viewProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders" id="ep-provider">
+ <?gmfgen generated="true"?>
+ <editpartProvider class="org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEEditPartProvider">
+ <Priority name="Lowest"/>
+ <object class="org.eclipse.gmf.runtime.notation.Diagram" id="generated-diagram">
+ <method name="getType()" value="TOE"/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-nodes">
+ <method name="getType()" value="2001,2002,2003,2004,3001,3002"/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Edge" id="generated-links">
+ <method name="getType()" value="4001,4002,4003"/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-labels">
+ <method name="getType()" value="5001,5006,5007,5008,5009,5010,5011,5012,5002,5003,5004,5005"/>
+ </object>
+ <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-compartments">
+ <method name="getType()" value="7001,7002"/>
+ </object>
+ <context views="generated-diagram,generated-nodes,generated-links,generated-labels,generated-compartments"/>
+ </editpartProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.emf.ui.modelingAssistantProviders" id="modelassist-provider">
+ <?gmfgen generated="true"?>
+ <modelingAssistantProvider class="org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEModelingAssistantProvider">
+ <Priority name="Lowest"/>
+ <object class="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.AllHolderEditPart" id="AllHolder_1000"/>
+ <object class="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeEditPart" id="Employee_2001"/>
+ <object class="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentEditPart" id="Department_2002"/>
+ <object class="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ProjectEditPart" id="Project_2003"/>
+ <object class="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerEditPart" id="Manager_2004"/>
+ <object class="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart" id="Employee_3001"/>
+ <object class="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Department2EditPart" id="Department_3002"/>
+ <context elements="AllHolder_1000,Employee_2001,Department_2002,Project_2003,Manager_2004,Employee_3001,Department_3002"/>
+ </modelingAssistantProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.common.ui.services.iconProviders" id="icon-provider">
+ <?gmfgen generated="true"?>
+ <IconProvider class="org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEIconProvider">
+ <Priority name="Low"/>
+ </IconProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.common.ui.services.parserProviders" id="parser-provider">
+ <?gmfgen generated="true"?>
+ <ParserProvider class="org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider">
+ <Priority name="Lowest"/>
+ </ParserProvider>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypes" id="element-types">
+ <?gmfgen generated="true"?>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <metamodelType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.AllHolder_1000"
+ name="%metatype.name.AllHolder_1000"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="AllHolder"
+ edithelper="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers.AllHolderEditHelper">
+ <param name="semanticHint" value="1000"/>
+ </metamodelType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <metamodelType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.Employee_2001"
+ name="%metatype.name.Employee_2001"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="Employee"
+ edithelper="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers.EmployeeEditHelper">
+ <param name="semanticHint" value="2001"/>
+ </metamodelType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <metamodelType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.Department_2002"
+ name="%metatype.name.Department_2002"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="Department"
+ edithelper="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers.DepartmentEditHelper">
+ <param name="semanticHint" value="2002"/>
+ </metamodelType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <metamodelType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.Project_2003"
+ name="%metatype.name.Project_2003"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="Project"
+ edithelper="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers.ProjectEditHelper">
+ <param name="semanticHint" value="2003"/>
+ </metamodelType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <metamodelType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.Manager_2004"
+ name="%metatype.name.Manager_2004"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="Manager"
+ edithelper="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers.ManagerEditHelper">
+ <param name="semanticHint" value="2004"/>
+ </metamodelType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <specializationType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.Employee_3001"
+ name="%metatype.name.Employee_3001"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
+ <specializes id="org.eclipse.gmf.examples.ocldriven.diagram.Employee_2001"/>
+ <param name="semanticHint" value="3001"/>
+ </specializationType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <specializationType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.Department_3002"
+ name="%metatype.name.Department_3002"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
+ <specializes id="org.eclipse.gmf.examples.ocldriven.diagram.Department_2002"/>
+ <param name="semanticHint" value="3002"/>
+ </specializationType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <specializationType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.ManagerManagedDepartment_4001"
+ name="%metatype.name.ManagerManagedDepartment_4001"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
+ <specializes id="org.eclipse.gmf.runtime.emf.type.core.null"/>
+ <param name="semanticHint" value="4001"/>
+ </specializationType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <specializationType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.ManagerLeads_4002"
+ name="%metatype.name.ManagerLeads_4002"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType">
+ <specializes id="org.eclipse.gmf.runtime.emf.type.core.null"/>
+ <param name="semanticHint" value="4002"/>
+ </specializationType>
+ </metamodel>
+ <metamodel nsURI="http://www.eclipse.org/examples/gmf/ocldriven/table-of-organization-and-equipment">
+ <metamodelType
+ id="org.eclipse.gmf.examples.ocldriven.diagram.Contribution_4003"
+ name="%metatype.name.Contribution_4003"
+ kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"
+ eclass="Contribution"
+ edithelper="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers.ContributionEditHelper">
+ <param name="semanticHint" value="4003"/>
+ </metamodelType>
+ </metamodel>
+ </extension>
+
+ <extension point="org.eclipse.gmf.runtime.emf.type.core.elementTypeBindings" id="element-types-bindings">
+ <?gmfgen generated="true"?>
+ <clientContext id="org.eclipse.gmf.examples.ocldriven.diagram.TypeContext">
+ <enablement>
+ <test
+ property="org.eclipse.gmf.runtime.emf.core.editingDomain"
+ value="org.eclipse.gmf.examples.ocldriven.diagram.EditingDomain"/>
+ </enablement>
+ </clientContext>
+ <binding context="org.eclipse.gmf.examples.ocldriven.diagram.TypeContext">
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.AllHolder_1000"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.Employee_2001"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.Department_2002"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.Project_2003"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.Manager_2004"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.Employee_3001"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.Department_3002"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.ManagerManagedDepartment_4001"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.ManagerLeads_4002"/>
+ <elementType ref="org.eclipse.gmf.examples.ocldriven.diagram.Contribution_4003"/>
+ <advice ref="org.eclipse.gmf.runtime.diagram.core.advice.notationDepdendents"/>
+ </binding>
+ </extension>
+ <extension point="org.eclipse.core.expressions.propertyTesters" id="navigator-proptest.isURIEditorInput">
+ <?gmfgen generated="true"?>
+ <propertyTester
+ id="org.eclipse.gmf.examples.ocldriven.diagram.URIEditorInputPropertyTester"
+ type="org.eclipse.emf.common.ui.URIEditorInput"
+ namespace="org.eclipse.gmf.examples.ocldriven.diagram"
+ properties="isURIEditorInput"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEUriEditorInputTester">
+ </propertyTester>
+ </extension>
+
+ <extension point="org.eclipse.ui.navigator.viewer" id="navigator-viewbinding">
+ <?gmfgen generated="true"?>
+ <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <contentExtension pattern="org.eclipse.gmf.examples.ocldriven.diagram.resourceContent"/>
+ <contentExtension pattern="org.eclipse.gmf.examples.ocldriven.diagram.domainResourceContent"/>
+ <contentExtension pattern="org.eclipse.gmf.examples.ocldriven.diagram.navigatorLinkHelper"/>
+ </includes>
+ </viewerContentBinding>
+ <viewerActionBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+ <includes>
+ <actionExtension pattern="org.eclipse.gmf.examples.ocldriven.diagram.navigatorActionProvider"/>
+ </includes>
+ </viewerActionBinding>
+ </extension>
+
+ <extension point="org.eclipse.ui.navigator.navigatorContent" id="navigator-content">
+ <?gmfgen generated="true"?>
+ <navigatorContent
+ id="org.eclipse.gmf.examples.ocldriven.diagram.resourceContent"
+ name="%navigatorContentName"
+ priority="normal"
+ contentProvider="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOENavigatorContentProvider"
+ labelProvider="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOENavigatorLabelProvider"
+ icon="icons/obj16/TOEDiagramFile.gif"
+ activeByDefault="true">
+ <triggerPoints>
+ <or>
+ <and>
+ <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.core.resources.extension" value="toed"/>
+ </and>
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEAbstractNavigatorItem"/>
+ </or>
+ </triggerPoints>
+ <possibleChildren>
+ <or>
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEAbstractNavigatorItem"/>
+ </or>
+ </possibleChildren>
+ <commonSorter
+ id="org.eclipse.gmf.examples.ocldriven.diagram.navigatorSorter"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOENavigatorSorter">
+ <parentExpression>
+ <or>
+ <and>
+ <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.core.resources.extension" value="toed"/>
+ </and>
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEAbstractNavigatorItem"/>
+ </or>
+ </parentExpression>
+ </commonSorter>
+ </navigatorContent>
+ <navigatorContent
+ id="org.eclipse.gmf.examples.ocldriven.diagram.domainResourceContent"
+ name="%domainNavigatorContentName"
+ priority="normal"
+ contentProvider="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEDomainNavigatorContentProvider"
+ labelProvider="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEDomainNavigatorLabelProvider"
+ icon="icons/obj16/TOEDiagramFile.gif"
+ activeByDefault="true">
+ <triggerPoints>
+ <or>
+ <and>
+ <instanceof value="org.eclipse.core.resources.IFile"/>
+ <test property="org.eclipse.core.resources.extension" value="toe"/>
+ </and>
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEDomainNavigatorItem"/>
+ </or>
+ </triggerPoints>
+ <possibleChildren>
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEDomainNavigatorItem"/>
+ </possibleChildren>
+ </navigatorContent>
+ <actionProvider
+ id="org.eclipse.gmf.examples.ocldriven.diagram.navigatorActionProvider"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOENavigatorActionProvider">
+ <enablement>
+ <or>
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEAbstractNavigatorItem"/>
+ </or>
+ </enablement>
+ </actionProvider>
+ </extension>
+
+ <extension point="org.eclipse.ui.navigator.linkHelper" id="navigator-linkhelper">
+ <?gmfgen generated="true"?>
+ <linkHelper
+ id="org.eclipse.gmf.examples.ocldriven.diagram.navigatorLinkHelper"
+ class="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOENavigatorLinkHelper">
+ <editorInputEnablement>
+ <and>
+ <instanceof value="org.eclipse.emf.common.ui.URIEditorInput"/>
+ <test property="org.eclipse.gmf.examples.ocldriven.diagram.isURIEditorInput"/>
+ </and>
+ </editorInputEnablement>
+ <selectionEnablement>
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.navigator.TOEAbstractNavigatorItem"/>
+ </selectionEnablement>
+ </linkHelper>
+ </extension>
+ <extension point="org.eclipse.ui.commands" id="update-cmd">
+ <?gmfgen generated="true"?>
+ <command
+ categoryId="org.eclipse.ui.category.edit"
+ defaultHandler="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramUpdateCommand"
+ description="%update.diagram.description"
+ id="org.eclipse.gmf.examples.ocldriven.toe.diagram.updateDiagram"
+ name="%update.diagram.name"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.bindings" id="update-cmd-binding">
+ <?gmfgen generated="true"?>
+ <key
+ commandId="org.eclipse.gmf.examples.ocldriven.toe.diagram.updateDiagram"
+ contextId="org.eclipse.gmf.examples.ocldriven.toe.diagram.ui.diagramContext"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="F5"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.menus" id="context-menus">
+ <?gmfgen generated="true"?>
+ <!-- menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=">
+ </menuContribution>
+ <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=">
+ </menuContribution -->
+ <menuContribution locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu">
+ <command commandId="org.eclipse.gmf.examples.ocldriven.diagram.LoadResourceAction">
+ <visibleWhen>
+ <and>
+ <with variable="activePartId"><equals value="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorID"/></with>
+ <with variable="selection"><iterate ifEmpty="false">
+ <instanceof value="org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.AllHolderEditPart"/>
+ </iterate></with>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+
+ <extension point="org.eclipse.ui.commands" id="menu-commands">
+ <?gmfgen generated="true"?>
+ <category id="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorID" name="%cmdcategory.name" description="%cmdcategory.desc"/>
+ <command id="org.eclipse.gmf.examples.ocldriven.diagram.LoadResourceAction"
+ name="Load Resource"
+ categoryId="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramEditorID"
+ defaultHandler="org.eclipse.gmf.examples.ocldriven.toe.diagram.part.LoadResourceAction"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.handlers" id="menu-handlers">
+ <?gmfgen generated="true"?>
+ </extension>
+
+ <!-- optionally, specify keybindings -->
+</plugin>
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionCreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionCreateCommand.java
new file mode 100644
index 000000000..9589bb907
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionCreateCommand.java
@@ -0,0 +1,153 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.AllHolder;
+import org.eclipse.gmf.examples.ocldriven.toe.Contribution;
+import org.eclipse.gmf.examples.ocldriven.toe.Employee;
+import org.eclipse.gmf.examples.ocldriven.toe.Project;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEFactory;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOEBaseItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+
+/**
+ * @generated
+ */
+public class ContributionCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final EObject source;
+
+ /**
+ * @generated
+ */
+ private final EObject target;
+
+ /**
+ * @generated
+ */
+ private final AllHolder container;
+
+ /**
+ * @generated
+ */
+ public ContributionCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ container = deduceContainer(source, target);
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Employee) {
+ return false;
+ }
+ if (target != null && false == target instanceof Project) {
+ return false;
+ }
+ if (getSource() == null) {
+ return true; // link creation is in progress; source is not defined yet
+ }
+ // target may be null here but it's possible to check constraint
+ if (getContainer() == null) {
+ return false;
+ }
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canCreateContribution_4003(getContainer(), getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+
+ Contribution newElement = TOEFactory.eINSTANCE.createContribution();
+ getContainer().getAll().add(newElement);
+ newElement.setEmployee(getSource());
+ newElement.setProject(getTarget());
+ doConfigure(newElement, monitor, info);
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Contribution newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ configureRequest.setParameter(CreateRelationshipRequest.SOURCE, getSource());
+ configureRequest.setParameter(CreateRelationshipRequest.TARGET, getTarget());
+ ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Employee getSource() {
+ return (Employee) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Project getTarget() {
+ return (Project) target;
+ }
+
+ /**
+ * @generated
+ */
+ public AllHolder getContainer() {
+ return container;
+ }
+
+ /**
+ * Default approach is to traverse ancestors of the source to find instance of container.
+ * Modify with appropriate logic.
+ * @generated
+ */
+ private static AllHolder deduceContainer(EObject source, EObject target) {
+ // Find container element for the new link.
+ // Climb up by containment hierarchy starting from the source
+ // and return the first element that is instance of the container class.
+ for (EObject element = source; element != null; element = element.eContainer()) {
+ if (element instanceof AllHolder) {
+ return (AllHolder) element;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionReorientCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionReorientCommand.java
new file mode 100644
index 000000000..6ef5d0975
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ContributionReorientCommand.java
@@ -0,0 +1,158 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.AllHolder;
+import org.eclipse.gmf.examples.ocldriven.toe.Contribution;
+import org.eclipse.gmf.examples.ocldriven.toe.Employee;
+import org.eclipse.gmf.examples.ocldriven.toe.Project;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOEBaseItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+
+/**
+ * @generated
+ */
+public class ContributionReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ContributionReorientCommand(ReorientRelationshipRequest request) {
+ super(request.getLabel(), request.getRelationship(), request);
+ reorientDirection = request.getDirection();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ if (false == getElementToEdit() instanceof Contribution) {
+ return false;
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return canReorientSource();
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
+ return canReorientTarget();
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientSource() {
+ if (!(oldEnd instanceof Employee && newEnd instanceof Employee)) {
+ return false;
+ }
+ Project target = getLink().getProject();
+ if (!(getLink().eContainer() instanceof AllHolder)) {
+ return false;
+ }
+ AllHolder container = (AllHolder) getLink().eContainer();
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canExistContribution_4003(container, getLink(), getNewSource(), target);
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Project && newEnd instanceof Project)) {
+ return false;
+ }
+ Employee source = getLink().getEmployee();
+ if (!(getLink().eContainer() instanceof AllHolder)) {
+ return false;
+ }
+ AllHolder container = (AllHolder) getLink().eContainer();
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canExistContribution_4003(container, getLink(), source, getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in reorient link command"); //$NON-NLS-1$
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return reorientSource();
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
+ return reorientTarget();
+ }
+ throw new IllegalStateException();
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientSource() throws ExecutionException {
+ getLink().setEmployee(getNewSource());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getLink().setProject(getNewTarget());
+ return CommandResult.newOKCommandResult(getLink());
+ }
+
+ /**
+ * @generated
+ */
+ protected Contribution getLink() {
+ return (Contribution) getElementToEdit();
+ }
+
+ /**
+ * @generated
+ */
+ protected Employee getOldSource() {
+ return (Employee) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Employee getNewSource() {
+ return (Employee) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Project getOldTarget() {
+ return (Project) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Project getNewTarget() {
+ return (Project) newEnd;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Department2CreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Department2CreateCommand.java
new file mode 100644
index 000000000..e165d3da3
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Department2CreateCommand.java
@@ -0,0 +1,78 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Department;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEFactory;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class Department2CreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ public Department2CreateCommand(CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ * @generated
+ */
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ return true;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Department newElement = TOEFactory.eINSTANCE.createDepartment();
+
+ Department owner = (Department) getElementToEdit();
+ owner.getSubDepartments().add(newElement);
+
+ doConfigure(newElement, monitor, info);
+
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Department newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/DepartmentCreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/DepartmentCreateCommand.java
new file mode 100644
index 000000000..c6f66b3ad
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/DepartmentCreateCommand.java
@@ -0,0 +1,79 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.AllHolder;
+import org.eclipse.gmf.examples.ocldriven.toe.Department;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEFactory;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class DepartmentCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ public DepartmentCreateCommand(CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ * @generated
+ */
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ return true;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Department newElement = TOEFactory.eINSTANCE.createDepartment();
+
+ AllHolder owner = (AllHolder) getElementToEdit();
+ owner.getAll().add(newElement);
+
+ doConfigure(newElement, monitor, info);
+
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Department newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Employee2CreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Employee2CreateCommand.java
new file mode 100644
index 000000000..343bcb5ec
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/Employee2CreateCommand.java
@@ -0,0 +1,79 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Department;
+import org.eclipse.gmf.examples.ocldriven.toe.Employee;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEFactory;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class Employee2CreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ public Employee2CreateCommand(CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ * @generated
+ */
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ return true;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Employee newElement = TOEFactory.eINSTANCE.createEmployee();
+
+ Department owner = (Department) getElementToEdit();
+ owner.getEmployees().add(newElement);
+
+ doConfigure(newElement, monitor, info);
+
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Employee newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/EmployeeCreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/EmployeeCreateCommand.java
new file mode 100644
index 000000000..55c30cd82
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/EmployeeCreateCommand.java
@@ -0,0 +1,79 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.AllHolder;
+import org.eclipse.gmf.examples.ocldriven.toe.Employee;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEFactory;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class EmployeeCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ public EmployeeCreateCommand(CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ * @generated
+ */
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ return true;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Employee newElement = TOEFactory.eINSTANCE.createEmployee();
+
+ AllHolder owner = (AllHolder) getElementToEdit();
+ owner.getAll().add(newElement);
+
+ doConfigure(newElement, monitor, info);
+
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Employee newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerCreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerCreateCommand.java
new file mode 100644
index 000000000..72f0dc698
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerCreateCommand.java
@@ -0,0 +1,79 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.AllHolder;
+import org.eclipse.gmf.examples.ocldriven.toe.Manager;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEFactory;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class ManagerCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ public ManagerCreateCommand(CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ * @generated
+ */
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ return true;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Manager newElement = TOEFactory.eINSTANCE.createManager();
+
+ AllHolder owner = (AllHolder) getElementToEdit();
+ owner.getAll().add(newElement);
+
+ doConfigure(newElement, monitor, info);
+
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Manager newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsCreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsCreateCommand.java
new file mode 100644
index 000000000..58401e6df
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsCreateCommand.java
@@ -0,0 +1,93 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Manager;
+import org.eclipse.gmf.examples.ocldriven.toe.Project;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOEBaseItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+
+/**
+ * @generated
+ */
+public class ManagerLeadsCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final EObject source;
+
+ /**
+ * @generated
+ */
+ private final EObject target;
+
+ /**
+ * @generated
+ */
+ public ManagerLeadsCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Manager) {
+ return false;
+ }
+ if (target != null && false == target instanceof Project) {
+ return false;
+ }
+ if (getSource() == null) {
+ return true; // link creation is in progress; source is not defined yet
+ }
+ // target may be null here but it's possible to check constraint
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canCreateManagerLeads_4002(getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+
+ if (getSource() != null && getTarget() != null) {
+ getSource().getLeads().add(getTarget());
+ }
+ return CommandResult.newOKCommandResult();
+
+ }
+
+ /**
+ * @generated
+ */
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Manager getSource() {
+ return (Manager) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Project getTarget() {
+ return (Project) target;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsReorientCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsReorientCommand.java
new file mode 100644
index 000000000..aa12eccab
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerLeadsReorientCommand.java
@@ -0,0 +1,148 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Manager;
+import org.eclipse.gmf.examples.ocldriven.toe.Project;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOEBaseItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+
+/**
+ * @generated
+ */
+public class ManagerLeadsReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject referenceOwner;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ManagerLeadsReorientCommand(ReorientReferenceRelationshipRequest request) {
+ super(request.getLabel(), null, request);
+ reorientDirection = request.getDirection();
+ referenceOwner = request.getReferenceOwner();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ if (false == referenceOwner instanceof Manager) {
+ return false;
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return canReorientSource();
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
+ return canReorientTarget();
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientSource() {
+ if (!(oldEnd instanceof Project && newEnd instanceof Manager)) {
+ return false;
+ }
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canExistManagerLeads_4002(getNewSource(), getOldTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Project && newEnd instanceof Project)) {
+ return false;
+ }
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canExistManagerLeads_4002(getOldSource(), getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in reorient link command"); //$NON-NLS-1$
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return reorientSource();
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
+ return reorientTarget();
+ }
+ throw new IllegalStateException();
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientSource() throws ExecutionException {
+ getOldSource().getLeads().remove(getOldTarget());
+ getNewSource().getLeads().add(getOldTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getOldSource().getLeads().remove(getOldTarget());
+ getOldSource().getLeads().add(getNewTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected Manager getOldSource() {
+ return (Manager) referenceOwner;
+ }
+
+ /**
+ * @generated
+ */
+ protected Manager getNewSource() {
+ return (Manager) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Project getOldTarget() {
+ return (Project) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Project getNewTarget() {
+ return (Project) newEnd;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentCreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentCreateCommand.java
new file mode 100644
index 000000000..c934f5f84
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentCreateCommand.java
@@ -0,0 +1,93 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Department;
+import org.eclipse.gmf.examples.ocldriven.toe.Manager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOEBaseItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+
+/**
+ * @generated
+ */
+public class ManagerManagedDepartmentCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final EObject source;
+
+ /**
+ * @generated
+ */
+ private final EObject target;
+
+ /**
+ * @generated
+ */
+ public ManagerManagedDepartmentCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ if (source == null && target == null) {
+ return false;
+ }
+ if (source != null && false == source instanceof Manager) {
+ return false;
+ }
+ if (target != null && false == target instanceof Department) {
+ return false;
+ }
+ if (getSource() == null) {
+ return true; // link creation is in progress; source is not defined yet
+ }
+ // target may be null here but it's possible to check constraint
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canCreateManagerManagedDepartment_4001(getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+
+ if (getSource() != null && getTarget() != null) {
+ getSource().setManagedDepartment(getTarget());
+ }
+ return CommandResult.newOKCommandResult();
+
+ }
+
+ /**
+ * @generated
+ */
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Manager getSource() {
+ return (Manager) source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Department getTarget() {
+ return (Department) target;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentReorientCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentReorientCommand.java
new file mode 100644
index 000000000..b29de1785
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ManagerManagedDepartmentReorientCommand.java
@@ -0,0 +1,147 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Department;
+import org.eclipse.gmf.examples.ocldriven.toe.Manager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOEBaseItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+
+/**
+ * @generated
+ */
+public class ManagerManagedDepartmentReorientCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ private final int reorientDirection;
+
+ /**
+ * @generated
+ */
+ private final EObject referenceOwner;
+
+ /**
+ * @generated
+ */
+ private final EObject oldEnd;
+
+ /**
+ * @generated
+ */
+ private final EObject newEnd;
+
+ /**
+ * @generated
+ */
+ public ManagerManagedDepartmentReorientCommand(ReorientReferenceRelationshipRequest request) {
+ super(request.getLabel(), null, request);
+ reorientDirection = request.getDirection();
+ referenceOwner = request.getReferenceOwner();
+ oldEnd = request.getOldRelationshipEnd();
+ newEnd = request.getNewRelationshipEnd();
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ if (false == referenceOwner instanceof Manager) {
+ return false;
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return canReorientSource();
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
+ return canReorientTarget();
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientSource() {
+ if (!(oldEnd instanceof Department && newEnd instanceof Manager)) {
+ return false;
+ }
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canExistManagerManagedDepartment_4001(getNewSource(), getOldTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean canReorientTarget() {
+ if (!(oldEnd instanceof Department && newEnd instanceof Department)) {
+ return false;
+ }
+ return TOEBaseItemSemanticEditPolicy.getLinkConstraints().canExistManagerManagedDepartment_4001(getOldSource(), getNewTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if (!canExecute()) {
+ throw new ExecutionException("Invalid arguments in reorient link command"); //$NON-NLS-1$
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_SOURCE) {
+ return reorientSource();
+ }
+ if (reorientDirection == ReorientRelationshipRequest.REORIENT_TARGET) {
+ return reorientTarget();
+ }
+ throw new IllegalStateException();
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientSource() throws ExecutionException {
+ getOldSource().setManagedDepartment(null);
+ getNewSource().setManagedDepartment(getOldTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult reorientTarget() throws ExecutionException {
+ getOldSource().setManagedDepartment(getNewTarget());
+ return CommandResult.newOKCommandResult(referenceOwner);
+ }
+
+ /**
+ * @generated
+ */
+ protected Manager getOldSource() {
+ return (Manager) referenceOwner;
+ }
+
+ /**
+ * @generated
+ */
+ protected Manager getNewSource() {
+ return (Manager) newEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Department getOldTarget() {
+ return (Department) oldEnd;
+ }
+
+ /**
+ * @generated
+ */
+ protected Department getNewTarget() {
+ return (Department) newEnd;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ProjectCreateCommand.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ProjectCreateCommand.java
new file mode 100644
index 000000000..a5f936b67
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/commands/ProjectCreateCommand.java
@@ -0,0 +1,79 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.AllHolder;
+import org.eclipse.gmf.examples.ocldriven.toe.Project;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEFactory;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class ProjectCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ public ProjectCreateCommand(CreateElementRequest req) {
+ super(req.getLabel(), null, req);
+ }
+
+ /**
+ * FIXME: replace with setElementToEdit()
+ * @generated
+ */
+ protected EObject getElementToEdit() {
+ EObject container = ((CreateElementRequest) getRequest()).getContainer();
+ if (container instanceof View) {
+ container = ((View) container).getElement();
+ }
+ return container;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ return true;
+
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ Project newElement = TOEFactory.eINSTANCE.createProject();
+
+ AllHolder owner = (AllHolder) getElementToEdit();
+ owner.getAll().add(newElement);
+
+ doConfigure(newElement, monitor, info);
+
+ ((CreateElementRequest) getRequest()).setNewElement(newElement);
+ return CommandResult.newOKCommandResult(newElement);
+ }
+
+ /**
+ * @generated
+ */
+ protected void doConfigure(Project newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IElementType elementType = ((CreateElementRequest) getRequest()).getElementType();
+ ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType);
+ configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext());
+ configureRequest.addParameters(getRequest().getParameters());
+ ICommand configureCommand = elementType.getEditCommand(configureRequest);
+ if (configureCommand != null && configureCommand.canExecute()) {
+ configureCommand.execute(monitor, info);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/AllHolderEditHelper.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/AllHolderEditHelper.java
new file mode 100644
index 000000000..f204eab44
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/AllHolderEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class AllHolderEditHelper extends TOEBaseEditHelper {
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ContributionEditHelper.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ContributionEditHelper.java
new file mode 100644
index 000000000..9c7c6fbb5
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ContributionEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class ContributionEditHelper extends TOEBaseEditHelper {
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/DepartmentEditHelper.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/DepartmentEditHelper.java
new file mode 100644
index 000000000..094a3aab7
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/DepartmentEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class DepartmentEditHelper extends TOEBaseEditHelper {
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/EmployeeEditHelper.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/EmployeeEditHelper.java
new file mode 100644
index 000000000..e6d03e631
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/EmployeeEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class EmployeeEditHelper extends TOEBaseEditHelper {
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ManagerEditHelper.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ManagerEditHelper.java
new file mode 100644
index 000000000..e81317d44
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ManagerEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class ManagerEditHelper extends TOEBaseEditHelper {
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ProjectEditHelper.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ProjectEditHelper.java
new file mode 100644
index 000000000..dd284c5fa
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/ProjectEditHelper.java
@@ -0,0 +1,7 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers;
+
+/**
+ * @generated
+ */
+public class ProjectEditHelper extends TOEBaseEditHelper {
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/TOEBaseEditHelper.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/TOEBaseEditHelper.java
new file mode 100644
index 000000000..5efa4c149
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/helpers/TOEBaseEditHelper.java
@@ -0,0 +1,86 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.helpers;
+
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
+import org.eclipse.gmf.runtime.emf.type.core.edithelper.IEditHelperAdvice;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest;
+
+/**
+ * @generated
+ */
+public class TOEBaseEditHelper extends AbstractEditHelper {
+
+ /**
+ * @generated
+ */
+ public static final String EDIT_POLICY_COMMAND = "edit policy command"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final String CONTEXT_ELEMENT_TYPE = "context element type"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ protected IEditHelperAdvice[] getEditHelperAdvice(IEditCommandRequest req) {
+ if (req.getParameter(CONTEXT_ELEMENT_TYPE) instanceof IElementType) {
+ return ElementTypeRegistry.getInstance().getEditHelperAdvice((IElementType) req.getParameter(CONTEXT_ELEMENT_TYPE));
+ }
+ return super.getEditHelperAdvice(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getInsteadCommand(IEditCommandRequest req) {
+ ICommand epCommand = (ICommand) req.getParameter(EDIT_POLICY_COMMAND);
+ req.setParameter(EDIT_POLICY_COMMAND, null);
+ ICommand ehCommand = super.getInsteadCommand(req);
+ if (epCommand == null) {
+ return ehCommand;
+ }
+ if (ehCommand == null) {
+ return epCommand;
+ }
+ CompositeCommand command = new CompositeCommand(null);
+ command.add(epCommand);
+ command.add(ehCommand);
+ return command;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getCreateCommand(CreateElementRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected ICommand getDestroyReferenceCommand(DestroyReferenceRequest req) {
+ return null;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/AllHolderEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/AllHolderEditPart.java
new file mode 100644
index 000000000..653a84e7e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/AllHolderEditPart.java
@@ -0,0 +1,81 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gmf.examples.ocldriven.diagram.custom.policies.TOECreationEditPolicyWithCustomReparent;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.AllHolderCanonicalEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.AllHolderItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class AllHolderEditPart extends DiagramEditPart {
+
+ /**
+ * @generated
+ */
+ public final static String MODEL_ID = "TOE"; //$NON-NLS-1$
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 1000;
+
+ /**
+ * @generated
+ */
+ public AllHolderEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AllHolderItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AllHolderCanonicalEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new TOECreationEditPolicyWithCustomReparent());
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ /*package-local*/static class NodeLabelDragPolicy extends NonResizableEditPolicy {
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List createSelectionHandles() {
+ MoveHandle h = new MoveHandle((GraphicalEditPart) getHost());
+ h.setBorder(null);
+ return Collections.singletonList(h);
+ }
+
+ /**
+ * @generated
+ */
+ public Command getCommand(Request request) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean understandsRequest(Request request) {
+ return false;
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ContributionEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ContributionEditPart.java
new file mode 100644
index 000000000..6a60dd4f2
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ContributionEditPart.java
@@ -0,0 +1,72 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ContributionConnectionPinForeground4003Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ContributionItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class ContributionEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 4003;
+
+ /**
+ * @generated
+ */
+ public ContributionEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ContributionItemSemanticEditPolicy());
+ installEditPolicy(ContributionConnectionPinForeground4003Policy.KEY, new ContributionConnectionPinForeground4003Policy());
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+
+ protected Connection createConnectionFigure() {
+ return new ContributionConnection();
+ }
+
+ /**
+ * @generated
+ */
+ public ContributionConnection getPrimaryShape() {
+ return (ContributionConnection) getFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public class ContributionConnection extends PolylineConnectionEx {
+
+ /**
+ * @generated
+ */
+ public ContributionConnection() {
+
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Department2EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Department2EditPart.java
new file mode 100644
index 000000000..316689334
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Department2EditPart.java
@@ -0,0 +1,484 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.BorderLayout;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.Department2ItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentPinForeground3002Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class Department2EditPart extends ShapeNodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3002;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public Department2EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new Department2ItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(DepartmentPinForeground3002Policy.KEY, new DepartmentPinForeground3002Policy());
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createNodeShape() {
+ return primaryShape = new DepartmentFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public DepartmentFigure getPrimaryShape() {
+ return (DepartmentFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DepartmentName2EditPart) {
+ ((DepartmentName2EditPart) childEditPart).setLabel(getPrimaryShape().getFigureDepartmentFigure_name());
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel5EditPart) {
+ ((WrappingLabel5EditPart) childEditPart).setLabel(getPrimaryShape().getFigureDepartmentFigure_ocl_gmf());
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel6EditPart) {
+ ((WrappingLabel6EditPart) childEditPart).setLabel(getPrimaryShape().getFigureDepartmentFigure_ocl_ia());
+ return true;
+ }
+ if (childEditPart instanceof DepartmentDepartment_staff2EditPart) {
+ IFigure pane = getPrimaryShape().getFigureDepartmentFigure_content_pane();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((DepartmentDepartment_staff2EditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DepartmentName2EditPart) {
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel5EditPart) {
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel6EditPart) {
+ return true;
+ }
+ if (childEditPart instanceof DepartmentDepartment_staff2EditPart) {
+ IFigure pane = getPrimaryShape().getFigureDepartmentFigure_content_pane();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.remove(((DepartmentDepartment_staff2EditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof DepartmentDepartment_staff2EditPart) {
+ return getPrimaryShape().getFigureDepartmentFigure_content_pane();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);
+ return result;
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+ protected NodeFigure createNodeFigure() {
+ NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new StackLayout());
+ IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+
+ /**
+ * Default implementation treats passed figure as content pane.
+ * Respects layout one may have set for generated figure.
+ * @param nodeShape instance of generated figure class
+ * @generated
+ */
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ if (nodeShape.getLayoutManager() == null) {
+ ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
+ layout.setSpacing(5);
+ nodeShape.setLayoutManager(layout);
+ }
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setBackgroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(width);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(TOEVisualIDRegistry.getType(DepartmentName2EditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnTarget() {
+ ArrayList<IElementType> types = new ArrayList<IElementType>(1);
+ types.add(TOEElementTypes.ManagerManagedDepartment_4001);
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMATypesForSource(IElementType relationshipType) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (relationshipType == TOEElementTypes.ManagerManagedDepartment_4001) {
+ types.add(TOEElementTypes.Manager_2004);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public class DepartmentFigure extends RectangleFigure {
+
+ /**
+ * @generated
+ */
+ private RectangleFigure fFigureDepartmentFigure_content_pane;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureDepartmentFigure_name;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureDepartmentFigure_ocl_gmf;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureDepartmentFigure_ocl_ia;
+
+ /**
+ * @generated
+ */
+ public DepartmentFigure() {
+
+ BorderLayout layoutThis = new BorderLayout();
+ this.setLayoutManager(layoutThis);
+
+ createContents();
+ }
+
+ /**
+ * @generated
+ */
+ private void createContents() {
+
+ RectangleFigure departmentFigure_name_container0 = new RectangleFigure();
+
+ this.add(departmentFigure_name_container0, BorderLayout.TOP);
+
+ ToolbarLayout layoutDepartmentFigure_name_container0 = new ToolbarLayout();
+ layoutDepartmentFigure_name_container0.setStretchMinorAxis(false);
+ layoutDepartmentFigure_name_container0.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_name_container0.setSpacing(5);
+ layoutDepartmentFigure_name_container0.setVertical(true);
+
+ departmentFigure_name_container0.setLayoutManager(layoutDepartmentFigure_name_container0);
+
+ fFigureDepartmentFigure_name = new WrappingLabel();
+
+ fFigureDepartmentFigure_name.setAlignment(PositionConstants.CENTER);
+
+ fFigureDepartmentFigure_name.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_name_container0.add(fFigureDepartmentFigure_name);
+
+ fFigureDepartmentFigure_content_pane = new RectangleFigure();
+
+ this.add(fFigureDepartmentFigure_content_pane, BorderLayout.CENTER);
+ fFigureDepartmentFigure_content_pane.setLayoutManager(new StackLayout());
+
+ RectangleFigure departmentFigure_labels_container0 = new RectangleFigure();
+
+ departmentFigure_labels_container0.setBorder(new MarginBorder(getMapMode().DPtoLP(2), getMapMode().DPtoLP(2), getMapMode().DPtoLP(2), getMapMode().DPtoLP(2)));
+
+ this.add(departmentFigure_labels_container0, BorderLayout.BOTTOM);
+
+ ToolbarLayout layoutDepartmentFigure_labels_container0 = new ToolbarLayout();
+ layoutDepartmentFigure_labels_container0.setStretchMinorAxis(false);
+ layoutDepartmentFigure_labels_container0.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_labels_container0.setSpacing(5);
+ layoutDepartmentFigure_labels_container0.setVertical(true);
+
+ departmentFigure_labels_container0.setLayoutManager(layoutDepartmentFigure_labels_container0);
+
+ RectangleFigure departmentFigure_firstRow1 = new RectangleFigure();
+
+ departmentFigure_firstRow1.setOutline(false);
+
+ departmentFigure_labels_container0.add(departmentFigure_firstRow1);
+
+ ToolbarLayout layoutDepartmentFigure_firstRow1 = new ToolbarLayout();
+ layoutDepartmentFigure_firstRow1.setStretchMinorAxis(false);
+ layoutDepartmentFigure_firstRow1.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_firstRow1.setSpacing(5);
+ layoutDepartmentFigure_firstRow1.setVertical(false);
+
+ departmentFigure_firstRow1.setLayoutManager(layoutDepartmentFigure_firstRow1);
+
+ WrappingLabel departmentFigure_fixed_total_salary_gmf2 = new WrappingLabel();
+
+ departmentFigure_fixed_total_salary_gmf2.setText("Total Salary (GMF):");
+
+ departmentFigure_fixed_total_salary_gmf2.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_firstRow1.add(departmentFigure_fixed_total_salary_gmf2);
+
+ fFigureDepartmentFigure_ocl_gmf = new WrappingLabel();
+
+ fFigureDepartmentFigure_ocl_gmf.setText("<gmf>");
+ fFigureDepartmentFigure_ocl_gmf.setForegroundColor(ColorConstants.red);
+
+ fFigureDepartmentFigure_ocl_gmf.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_firstRow1.add(fFigureDepartmentFigure_ocl_gmf);
+
+ RectangleFigure departmentFigure_secondRow1 = new RectangleFigure();
+
+ departmentFigure_secondRow1.setOutline(false);
+
+ departmentFigure_labels_container0.add(departmentFigure_secondRow1);
+
+ ToolbarLayout layoutDepartmentFigure_secondRow1 = new ToolbarLayout();
+ layoutDepartmentFigure_secondRow1.setStretchMinorAxis(false);
+ layoutDepartmentFigure_secondRow1.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_secondRow1.setSpacing(5);
+ layoutDepartmentFigure_secondRow1.setVertical(false);
+
+ departmentFigure_secondRow1.setLayoutManager(layoutDepartmentFigure_secondRow1);
+
+ WrappingLabel departmentFigure_fixed_total_salary_ia2 = new WrappingLabel();
+
+ departmentFigure_fixed_total_salary_ia2.setText("Total Salary (IA):");
+
+ departmentFigure_fixed_total_salary_ia2.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_secondRow1.add(departmentFigure_fixed_total_salary_ia2);
+
+ fFigureDepartmentFigure_ocl_ia = new WrappingLabel();
+
+ fFigureDepartmentFigure_ocl_ia.setText("<ia>");
+ fFigureDepartmentFigure_ocl_ia.setForegroundColor(ColorConstants.yellow);
+
+ fFigureDepartmentFigure_ocl_ia.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_secondRow1.add(fFigureDepartmentFigure_ocl_ia);
+
+ }
+
+ /**
+ * @generated
+ */
+ public RectangleFigure getFigureDepartmentFigure_content_pane() {
+ return fFigureDepartmentFigure_content_pane;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureDepartmentFigure_name() {
+ return fFigureDepartmentFigure_name;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureDepartmentFigure_ocl_gmf() {
+ return fFigureDepartmentFigure_ocl_gmf;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureDepartmentFigure_ocl_ia() {
+ return fFigureDepartmentFigure_ocl_ia;
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staff2EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staff2EditPart.java
new file mode 100644
index 000000000..eab656328
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staff2EditPart.java
@@ -0,0 +1,70 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gmf.examples.ocldriven.diagram.custom.policies.TOECreationEditPolicyWithCustomReparent;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentDepartment_staff2CanonicalEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentDepartment_staff2ItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.Messages;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class DepartmentDepartment_staff2EditPart extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 7002;
+
+ /**
+ * @generated
+ */
+ public DepartmentDepartment_staff2EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ public String getCompartmentName() {
+ return Messages.DepartmentDepartment_staff2EditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure createFigure() {
+ ResizableCompartmentFigure result = (ResizableCompartmentFigure) super.createFigure();
+ result.setTitleVisibility(false);
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DepartmentDepartment_staff2ItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new DepartmentDepartment_staff2CanonicalEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new TOECreationEditPolicyWithCustomReparent());
+ }
+
+ /**
+ * @generated
+ */
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staffEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staffEditPart.java
new file mode 100644
index 000000000..5b441aeaf
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentDepartment_staffEditPart.java
@@ -0,0 +1,70 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.gmf.examples.ocldriven.diagram.custom.policies.TOECreationEditPolicyWithCustomReparent;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentDepartment_staffCanonicalEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentDepartment_staffItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.Messages;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class DepartmentDepartment_staffEditPart extends ShapeCompartmentEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 7001;
+
+ /**
+ * @generated
+ */
+ public DepartmentDepartment_staffEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ public String getCompartmentName() {
+ return Messages.DepartmentDepartment_staffEditPart_title;
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure createFigure() {
+ ResizableCompartmentFigure result = (ResizableCompartmentFigure) super.createFigure();
+ result.setTitleVisibility(false);
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DepartmentDepartment_staffItemSemanticEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
+ installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
+ installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new DepartmentDepartment_staffCanonicalEditPolicy());
+ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new TOECreationEditPolicyWithCustomReparent());
+ }
+
+ /**
+ * @generated
+ */
+ protected void setRatio(Double ratio) {
+ if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
+ super.setRatio(ratio);
+ }
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentEditPart.java
new file mode 100644
index 000000000..96cf6563e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentEditPart.java
@@ -0,0 +1,484 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.BorderLayout;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentPinForeground2002Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class DepartmentEditPart extends ShapeNodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2002;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public DepartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DepartmentItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(DepartmentPinForeground2002Policy.KEY, new DepartmentPinForeground2002Policy());
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createNodeShape() {
+ return primaryShape = new DepartmentFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public DepartmentFigure getPrimaryShape() {
+ return (DepartmentFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DepartmentNameEditPart) {
+ ((DepartmentNameEditPart) childEditPart).setLabel(getPrimaryShape().getFigureDepartmentFigure_name());
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabelEditPart) {
+ ((WrappingLabelEditPart) childEditPart).setLabel(getPrimaryShape().getFigureDepartmentFigure_ocl_gmf());
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel2EditPart) {
+ ((WrappingLabel2EditPart) childEditPart).setLabel(getPrimaryShape().getFigureDepartmentFigure_ocl_ia());
+ return true;
+ }
+ if (childEditPart instanceof DepartmentDepartment_staffEditPart) {
+ IFigure pane = getPrimaryShape().getFigureDepartmentFigure_content_pane();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.add(((DepartmentDepartment_staffEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof DepartmentNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabelEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel2EditPart) {
+ return true;
+ }
+ if (childEditPart instanceof DepartmentDepartment_staffEditPart) {
+ IFigure pane = getPrimaryShape().getFigureDepartmentFigure_content_pane();
+ setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
+ pane.remove(((DepartmentDepartment_staffEditPart) childEditPart).getFigure());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ if (editPart instanceof DepartmentDepartment_staffEditPart) {
+ return getPrimaryShape().getFigureDepartmentFigure_content_pane();
+ }
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);
+ return result;
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+ protected NodeFigure createNodeFigure() {
+ NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new StackLayout());
+ IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+
+ /**
+ * Default implementation treats passed figure as content pane.
+ * Respects layout one may have set for generated figure.
+ * @param nodeShape instance of generated figure class
+ * @generated
+ */
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ if (nodeShape.getLayoutManager() == null) {
+ ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
+ layout.setSpacing(5);
+ nodeShape.setLayoutManager(layout);
+ }
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setBackgroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(width);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(TOEVisualIDRegistry.getType(DepartmentNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnTarget() {
+ ArrayList<IElementType> types = new ArrayList<IElementType>(1);
+ types.add(TOEElementTypes.ManagerManagedDepartment_4001);
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMATypesForSource(IElementType relationshipType) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (relationshipType == TOEElementTypes.ManagerManagedDepartment_4001) {
+ types.add(TOEElementTypes.Manager_2004);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public class DepartmentFigure extends RectangleFigure {
+
+ /**
+ * @generated
+ */
+ private RectangleFigure fFigureDepartmentFigure_content_pane;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureDepartmentFigure_name;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureDepartmentFigure_ocl_gmf;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureDepartmentFigure_ocl_ia;
+
+ /**
+ * @generated
+ */
+ public DepartmentFigure() {
+
+ BorderLayout layoutThis = new BorderLayout();
+ this.setLayoutManager(layoutThis);
+
+ createContents();
+ }
+
+ /**
+ * @generated
+ */
+ private void createContents() {
+
+ RectangleFigure departmentFigure_name_container0 = new RectangleFigure();
+
+ this.add(departmentFigure_name_container0, BorderLayout.TOP);
+
+ ToolbarLayout layoutDepartmentFigure_name_container0 = new ToolbarLayout();
+ layoutDepartmentFigure_name_container0.setStretchMinorAxis(false);
+ layoutDepartmentFigure_name_container0.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_name_container0.setSpacing(5);
+ layoutDepartmentFigure_name_container0.setVertical(true);
+
+ departmentFigure_name_container0.setLayoutManager(layoutDepartmentFigure_name_container0);
+
+ fFigureDepartmentFigure_name = new WrappingLabel();
+
+ fFigureDepartmentFigure_name.setAlignment(PositionConstants.CENTER);
+
+ fFigureDepartmentFigure_name.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_name_container0.add(fFigureDepartmentFigure_name);
+
+ fFigureDepartmentFigure_content_pane = new RectangleFigure();
+
+ this.add(fFigureDepartmentFigure_content_pane, BorderLayout.CENTER);
+ fFigureDepartmentFigure_content_pane.setLayoutManager(new StackLayout());
+
+ RectangleFigure departmentFigure_labels_container0 = new RectangleFigure();
+
+ departmentFigure_labels_container0.setBorder(new MarginBorder(getMapMode().DPtoLP(2), getMapMode().DPtoLP(2), getMapMode().DPtoLP(2), getMapMode().DPtoLP(2)));
+
+ this.add(departmentFigure_labels_container0, BorderLayout.BOTTOM);
+
+ ToolbarLayout layoutDepartmentFigure_labels_container0 = new ToolbarLayout();
+ layoutDepartmentFigure_labels_container0.setStretchMinorAxis(false);
+ layoutDepartmentFigure_labels_container0.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_labels_container0.setSpacing(5);
+ layoutDepartmentFigure_labels_container0.setVertical(true);
+
+ departmentFigure_labels_container0.setLayoutManager(layoutDepartmentFigure_labels_container0);
+
+ RectangleFigure departmentFigure_firstRow1 = new RectangleFigure();
+
+ departmentFigure_firstRow1.setOutline(false);
+
+ departmentFigure_labels_container0.add(departmentFigure_firstRow1);
+
+ ToolbarLayout layoutDepartmentFigure_firstRow1 = new ToolbarLayout();
+ layoutDepartmentFigure_firstRow1.setStretchMinorAxis(false);
+ layoutDepartmentFigure_firstRow1.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_firstRow1.setSpacing(5);
+ layoutDepartmentFigure_firstRow1.setVertical(false);
+
+ departmentFigure_firstRow1.setLayoutManager(layoutDepartmentFigure_firstRow1);
+
+ WrappingLabel departmentFigure_fixed_total_salary_gmf2 = new WrappingLabel();
+
+ departmentFigure_fixed_total_salary_gmf2.setText("Total Salary (GMF):");
+
+ departmentFigure_fixed_total_salary_gmf2.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_firstRow1.add(departmentFigure_fixed_total_salary_gmf2);
+
+ fFigureDepartmentFigure_ocl_gmf = new WrappingLabel();
+
+ fFigureDepartmentFigure_ocl_gmf.setText("<gmf>");
+ fFigureDepartmentFigure_ocl_gmf.setForegroundColor(ColorConstants.red);
+
+ fFigureDepartmentFigure_ocl_gmf.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_firstRow1.add(fFigureDepartmentFigure_ocl_gmf);
+
+ RectangleFigure departmentFigure_secondRow1 = new RectangleFigure();
+
+ departmentFigure_secondRow1.setOutline(false);
+
+ departmentFigure_labels_container0.add(departmentFigure_secondRow1);
+
+ ToolbarLayout layoutDepartmentFigure_secondRow1 = new ToolbarLayout();
+ layoutDepartmentFigure_secondRow1.setStretchMinorAxis(false);
+ layoutDepartmentFigure_secondRow1.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutDepartmentFigure_secondRow1.setSpacing(5);
+ layoutDepartmentFigure_secondRow1.setVertical(false);
+
+ departmentFigure_secondRow1.setLayoutManager(layoutDepartmentFigure_secondRow1);
+
+ WrappingLabel departmentFigure_fixed_total_salary_ia2 = new WrappingLabel();
+
+ departmentFigure_fixed_total_salary_ia2.setText("Total Salary (IA):");
+
+ departmentFigure_fixed_total_salary_ia2.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_secondRow1.add(departmentFigure_fixed_total_salary_ia2);
+
+ fFigureDepartmentFigure_ocl_ia = new WrappingLabel();
+
+ fFigureDepartmentFigure_ocl_ia.setText("<ia>");
+ fFigureDepartmentFigure_ocl_ia.setForegroundColor(ColorConstants.yellow);
+
+ fFigureDepartmentFigure_ocl_ia.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ departmentFigure_secondRow1.add(fFigureDepartmentFigure_ocl_ia);
+
+ }
+
+ /**
+ * @generated
+ */
+ public RectangleFigure getFigureDepartmentFigure_content_pane() {
+ return fFigureDepartmentFigure_content_pane;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureDepartmentFigure_name() {
+ return fFigureDepartmentFigure_name;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureDepartmentFigure_ocl_gmf() {
+ return fFigureDepartmentFigure_ocl_gmf;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureDepartmentFigure_ocl_ia() {
+ return fFigureDepartmentFigure_ocl_ia;
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentName2EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentName2EditPart.java
new file mode 100644
index 000000000..2dbe6bba2
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentName2EditPart.java
@@ -0,0 +1,534 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class DepartmentName2EditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5003;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public DepartmentName2EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Department_3002, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentName2EditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ if (getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentNameEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentNameEditPart.java
new file mode 100644
index 000000000..d3ca9b381
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/DepartmentNameEditPart.java
@@ -0,0 +1,534 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class DepartmentNameEditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5006;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public DepartmentNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Department_2002, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ if (getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Employee2EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Employee2EditPart.java
new file mode 100644
index 000000000..d87e3081e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/Employee2EditPart.java
@@ -0,0 +1,322 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.BorderLayout;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.examples.ocldriven.diagram.figures.StickManWithNumber;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.Employee2ItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinCounter3001Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinVisible3001Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class Employee2EditPart extends AbstractBorderedShapeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 3001;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public Employee2EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new Employee2ItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EmployeePinCounter3001Policy.KEY, new EmployeePinCounter3001Policy());
+ installEditPolicy(EmployeePinVisible3001Policy.KEY, new EmployeePinVisible3001Policy());
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ View childView = (View) child.getModel();
+ switch (TOEVisualIDRegistry.getVisualID(childView)) {
+ case EmployeeName2EditPart.VISUAL_ID:
+ return new BorderItemSelectionEditPolicy() {
+
+ protected List createSelectionHandles() {
+ MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost());
+ mh.setBorder(null);
+ return Collections.singletonList(mh);
+ }
+ };
+ }
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createNodeShape() {
+ return primaryShape = new EmployeeFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public EmployeeFigure getPrimaryShape() {
+ return (EmployeeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
+ if (borderItemEditPart instanceof EmployeeName2EditPart) {
+ BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
+ locator.setBorderItemOffset(new Dimension(-20, -20));
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else {
+ super.addBorderItem(borderItemContainer, borderItemEditPart);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);
+ return result;
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+ protected NodeFigure createMainFigure() {
+ NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new StackLayout());
+ IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+
+ /**
+ * Default implementation treats passed figure as content pane.
+ * Respects layout one may have set for generated figure.
+ * @param nodeShape instance of generated figure class
+ * @generated
+ */
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setBackgroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(width);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(TOEVisualIDRegistry.getType(EmployeeName2EditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnSource() {
+ ArrayList<IElementType> types = new ArrayList<IElementType>(1);
+ types.add(TOEElementTypes.Contribution_4003);
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnSourceAndTarget(IGraphicalEditPart targetEditPart) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (targetEditPart instanceof ProjectEditPart) {
+ types.add(TOEElementTypes.Contribution_4003);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMATypesForTarget(IElementType relationshipType) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (relationshipType == TOEElementTypes.Contribution_4003) {
+ types.add(TOEElementTypes.Project_2003);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public class EmployeeFigure extends RoundedRectangle {
+
+ /**
+ * @generated
+ */
+ private StickManWithNumber fInnerEmployeeFigure;
+
+ /**
+ * @generated
+ */
+ public EmployeeFigure() {
+
+ BorderLayout layoutThis = new BorderLayout();
+ this.setLayoutManager(layoutThis);
+
+ this.setCornerDimensions(new Dimension(getMapMode().DPtoLP(8), getMapMode().DPtoLP(8)));
+ this.setBackgroundColor(ColorConstants.green);
+
+ this.setBorder(new MarginBorder(getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10)));
+ createContents();
+ }
+
+ /**
+ * @generated
+ */
+ private void createContents() {
+
+ RectangleFigure employeeMiddleFigure0 = new RectangleFigure();
+
+ employeeMiddleFigure0.setBorder(new MarginBorder(getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10)));
+
+ this.add(employeeMiddleFigure0, BorderLayout.CENTER);
+
+ BorderLayout layoutEmployeeMiddleFigure0 = new BorderLayout();
+ employeeMiddleFigure0.setLayoutManager(layoutEmployeeMiddleFigure0);
+
+ fInnerEmployeeFigure = new StickManWithNumber();
+
+ employeeMiddleFigure0.add(fInnerEmployeeFigure, BorderLayout.CENTER);
+
+ }
+
+ /**
+ * @generated
+ */
+ public StickManWithNumber getInnerEmployeeFigure() {
+ return fInnerEmployeeFigure;
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeEditPart.java
new file mode 100644
index 000000000..c16ef96dd
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeEditPart.java
@@ -0,0 +1,322 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.BorderLayout;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.examples.ocldriven.diagram.figures.StickManWithNumber;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeeItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinCounter2001Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinVisible2001Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class EmployeeEditPart extends AbstractBorderedShapeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2001;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public EmployeeEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new EmployeeItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(EmployeePinCounter2001Policy.KEY, new EmployeePinCounter2001Policy());
+ installEditPolicy(EmployeePinVisible2001Policy.KEY, new EmployeePinVisible2001Policy());
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ View childView = (View) child.getModel();
+ switch (TOEVisualIDRegistry.getVisualID(childView)) {
+ case EmployeeNameEditPart.VISUAL_ID:
+ return new BorderItemSelectionEditPolicy() {
+
+ protected List createSelectionHandles() {
+ MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost());
+ mh.setBorder(null);
+ return Collections.singletonList(mh);
+ }
+ };
+ }
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createNodeShape() {
+ return primaryShape = new EmployeeFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public EmployeeFigure getPrimaryShape() {
+ return (EmployeeFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
+ if (borderItemEditPart instanceof EmployeeNameEditPart) {
+ BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
+ locator.setBorderItemOffset(new Dimension(-20, -20));
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else {
+ super.addBorderItem(borderItemContainer, borderItemEditPart);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);
+ return result;
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+ protected NodeFigure createMainFigure() {
+ NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new StackLayout());
+ IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+
+ /**
+ * Default implementation treats passed figure as content pane.
+ * Respects layout one may have set for generated figure.
+ * @param nodeShape instance of generated figure class
+ * @generated
+ */
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setBackgroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(width);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(TOEVisualIDRegistry.getType(EmployeeNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnSource() {
+ ArrayList<IElementType> types = new ArrayList<IElementType>(1);
+ types.add(TOEElementTypes.Contribution_4003);
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnSourceAndTarget(IGraphicalEditPart targetEditPart) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (targetEditPart instanceof ProjectEditPart) {
+ types.add(TOEElementTypes.Contribution_4003);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMATypesForTarget(IElementType relationshipType) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (relationshipType == TOEElementTypes.Contribution_4003) {
+ types.add(TOEElementTypes.Project_2003);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public class EmployeeFigure extends RoundedRectangle {
+
+ /**
+ * @generated
+ */
+ private StickManWithNumber fInnerEmployeeFigure;
+
+ /**
+ * @generated
+ */
+ public EmployeeFigure() {
+
+ BorderLayout layoutThis = new BorderLayout();
+ this.setLayoutManager(layoutThis);
+
+ this.setCornerDimensions(new Dimension(getMapMode().DPtoLP(8), getMapMode().DPtoLP(8)));
+ this.setBackgroundColor(ColorConstants.green);
+
+ this.setBorder(new MarginBorder(getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10)));
+ createContents();
+ }
+
+ /**
+ * @generated
+ */
+ private void createContents() {
+
+ RectangleFigure employeeMiddleFigure0 = new RectangleFigure();
+
+ employeeMiddleFigure0.setBorder(new MarginBorder(getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10), getMapMode().DPtoLP(10)));
+
+ this.add(employeeMiddleFigure0, BorderLayout.CENTER);
+
+ BorderLayout layoutEmployeeMiddleFigure0 = new BorderLayout();
+ employeeMiddleFigure0.setLayoutManager(layoutEmployeeMiddleFigure0);
+
+ fInnerEmployeeFigure = new StickManWithNumber();
+
+ employeeMiddleFigure0.add(fInnerEmployeeFigure, BorderLayout.CENTER);
+
+ }
+
+ /**
+ * @generated
+ */
+ public StickManWithNumber getInnerEmployeeFigure() {
+ return fInnerEmployeeFigure;
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeName2EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeName2EditPart.java
new file mode 100644
index 000000000..30d1d9bcf
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeName2EditPart.java
@@ -0,0 +1,558 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class EmployeeName2EditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5002;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeName2EditPart.VISUAL_ID), new Point(0, 0));
+ }
+
+ /**
+ * @generated
+ */
+ public EmployeeName2EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ public IBorderItemLocator getBorderItemLocator() {
+ IFigure parentFigure = getFigure().getParent();
+ if (parentFigure != null && parentFigure.getLayoutManager() != null) {
+ Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure());
+ return (IBorderItemLocator) constraint;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void refreshBounds() {
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height));
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Employee_3001, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeName2EditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ if (getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeNameEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeNameEditPart.java
new file mode 100644
index 000000000..aff48d44c
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/EmployeeNameEditPart.java
@@ -0,0 +1,558 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class EmployeeNameEditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5001;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeNameEditPart.VISUAL_ID), new Point(0, 0));
+ }
+
+ /**
+ * @generated
+ */
+ public EmployeeNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ public IBorderItemLocator getBorderItemLocator() {
+ IFigure parentFigure = getFigure().getParent();
+ if (parentFigure != null && parentFigure.getLayoutManager() != null) {
+ Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure());
+ return (IBorderItemLocator) constraint;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void refreshBounds() {
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height));
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Employee_2001, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ if (getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerEditPart.java
new file mode 100644
index 000000000..b2ae32820
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerEditPart.java
@@ -0,0 +1,294 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.examples.ocldriven.diagram.figures.StickManWithNumber;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ManagerItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ManagerPinBackgroundRGB2004Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ManagerEditPart extends AbstractBorderedShapeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2004;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ManagerEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ManagerItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ installEditPolicy(ManagerPinBackgroundRGB2004Policy.KEY, new ManagerPinBackgroundRGB2004Policy());
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ View childView = (View) child.getModel();
+ switch (TOEVisualIDRegistry.getVisualID(childView)) {
+ case ManagerNameEditPart.VISUAL_ID:
+ return new BorderItemSelectionEditPolicy() {
+
+ protected List createSelectionHandles() {
+ MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost());
+ mh.setBorder(null);
+ return Collections.singletonList(mh);
+ }
+ };
+ }
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createNodeShape() {
+ return primaryShape = new ManagerFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public ManagerFigure getPrimaryShape() {
+ return (ManagerFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) {
+ if (borderItemEditPart instanceof ManagerNameEditPart) {
+ BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
+ locator.setBorderItemOffset(new Dimension(-20, -20));
+ borderItemContainer.add(borderItemEditPart.getFigure(), locator);
+ } else {
+ super.addBorderItem(borderItemContainer, borderItemEditPart);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);
+ return result;
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+ protected NodeFigure createMainFigure() {
+ NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new StackLayout());
+ IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+
+ /**
+ * Default implementation treats passed figure as content pane.
+ * Respects layout one may have set for generated figure.
+ * @param nodeShape instance of generated figure class
+ * @generated
+ */
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setBackgroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(width);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(TOEVisualIDRegistry.getType(ManagerNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnSource() {
+ ArrayList<IElementType> types = new ArrayList<IElementType>(3);
+ types.add(TOEElementTypes.ManagerManagedDepartment_4001);
+ types.add(TOEElementTypes.ManagerLeads_4002);
+ types.add(TOEElementTypes.Contribution_4003);
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnSourceAndTarget(IGraphicalEditPart targetEditPart) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (targetEditPart instanceof DepartmentEditPart) {
+ types.add(TOEElementTypes.ManagerManagedDepartment_4001);
+ }
+ if (targetEditPart instanceof Department2EditPart) {
+ types.add(TOEElementTypes.ManagerManagedDepartment_4001);
+ }
+ if (targetEditPart instanceof ProjectEditPart) {
+ types.add(TOEElementTypes.ManagerLeads_4002);
+ }
+ if (targetEditPart instanceof ProjectEditPart) {
+ types.add(TOEElementTypes.Contribution_4003);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMATypesForTarget(IElementType relationshipType) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (relationshipType == TOEElementTypes.ManagerManagedDepartment_4001) {
+ types.add(TOEElementTypes.Department_2002);
+ types.add(TOEElementTypes.Department_3002);
+ } else if (relationshipType == TOEElementTypes.ManagerLeads_4002) {
+ types.add(TOEElementTypes.Project_2003);
+ } else if (relationshipType == TOEElementTypes.Contribution_4003) {
+ types.add(TOEElementTypes.Project_2003);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public class ManagerFigure extends StickManWithNumber {
+
+ /**
+ * @generated
+ */
+ public ManagerFigure() {
+
+ this.setForegroundColor(ColorConstants.red);
+ this.setBackgroundColor(ColorConstants.yellow);
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerLeadsEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerLeadsEditPart.java
new file mode 100644
index 000000000..2469a16b1
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerLeadsEditPart.java
@@ -0,0 +1,76 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.LeadsProjectConnectionPinForeground4002Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.LeadsProjectConnectionPinLineWidth4002Policy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ManagerLeadsItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class ManagerLeadsEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 4002;
+
+ /**
+ * @generated
+ */
+ public ManagerLeadsEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ManagerLeadsItemSemanticEditPolicy());
+ installEditPolicy(LeadsProjectConnectionPinForeground4002Policy.KEY, new LeadsProjectConnectionPinForeground4002Policy());
+ installEditPolicy(LeadsProjectConnectionPinLineWidth4002Policy.KEY, new LeadsProjectConnectionPinLineWidth4002Policy());
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+
+ protected Connection createConnectionFigure() {
+ return new LeadsProjectConnection();
+ }
+
+ /**
+ * @generated
+ */
+ public LeadsProjectConnection getPrimaryShape() {
+ return (LeadsProjectConnection) getFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public class LeadsProjectConnection extends PolylineConnectionEx {
+
+ /**
+ * @generated
+ */
+ public LeadsProjectConnection() {
+ this.setLineStyle(Graphics.LINE_DASH);
+
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerManagedDepartmentEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerManagedDepartmentEditPart.java
new file mode 100644
index 000000000..4276bfc46
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerManagedDepartmentEditPart.java
@@ -0,0 +1,72 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ManagerManagedDepartmentItemSemanticEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class ManagerManagedDepartmentEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 4001;
+
+ /**
+ * @generated
+ */
+ public ManagerManagedDepartmentEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ManagerManagedDepartmentItemSemanticEditPolicy());
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+
+ protected Connection createConnectionFigure() {
+ return new ManagesDepartmentConnection();
+ }
+
+ /**
+ * @generated
+ */
+ public ManagesDepartmentConnection getPrimaryShape() {
+ return (ManagesDepartmentConnection) getFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public class ManagesDepartmentConnection extends PolylineConnectionEx {
+
+ /**
+ * @generated
+ */
+ public ManagesDepartmentConnection() {
+ this.setForegroundColor(ColorConstants.blue);
+
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerNameEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerNameEditPart.java
new file mode 100644
index 000000000..25ca9a30d
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ManagerNameEditPart.java
@@ -0,0 +1,558 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class ManagerNameEditPart extends LabelEditPart implements ITextAwareEditPart, IBorderItemEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5012;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ static {
+ registerSnapBackPosition(TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerNameEditPart.VISUAL_ID), new Point(0, 0));
+ }
+
+ /**
+ * @generated
+ */
+ public ManagerNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ public IBorderItemLocator getBorderItemLocator() {
+ IFigure parentFigure = getFigure().getParent();
+ if (parentFigure != null && parentFigure.getLayoutManager() != null) {
+ Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure());
+ return (IBorderItemLocator) constraint;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public void refreshBounds() {
+ int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue();
+ int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue();
+ int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue();
+ int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
+ getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height));
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(IFigure figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Manager_2004, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ if (getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ IFigure label = createFigurePrim();
+ defaultText = getLabelTextHelper(label);
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigurePrim() {
+ return new WrappingLabel();
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectEditPart.java
new file mode 100644
index 000000000..c8a773920
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectEditPart.java
@@ -0,0 +1,418 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.BorderLayout;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.Shape;
+import org.eclipse.draw2d.StackLayout;
+import org.eclipse.draw2d.ToolbarLayout;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.LayoutEditPolicy;
+import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ProjectItemSemanticEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
+import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ProjectEditPart extends ShapeNodeEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 2003;
+
+ /**
+ * @generated
+ */
+ protected IFigure contentPane;
+
+ /**
+ * @generated
+ */
+ protected IFigure primaryShape;
+
+ /**
+ * @generated
+ */
+ public ProjectEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ProjectItemSemanticEditPolicy());
+ installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
+ // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
+ // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+ }
+
+ /**
+ * @generated
+ */
+ protected LayoutEditPolicy createLayoutEditPolicy() {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() {
+
+ protected EditPolicy createChildEditPolicy(EditPart child) {
+ EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (result == null) {
+ result = new NonResizableEditPolicy();
+ }
+ return result;
+ }
+
+ protected Command getMoveChildrenCommand(Request request) {
+ return null;
+ }
+
+ protected Command getCreateCommand(CreateRequest request) {
+ return null;
+ }
+ };
+ return lep;
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createNodeShape() {
+ return primaryShape = new ProjectFigure();
+ }
+
+ /**
+ * @generated
+ */
+ public ProjectFigure getPrimaryShape() {
+ return (ProjectFigure) primaryShape;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean addFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ProjectNameEditPart) {
+ ((ProjectNameEditPart) childEditPart).setLabel(getPrimaryShape().getFigureProjectFigure_name());
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel3EditPart) {
+ ((WrappingLabel3EditPart) childEditPart).setLabel(getPrimaryShape().getFigureProjectFigure_ocl_gmf());
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel4EditPart) {
+ ((WrappingLabel4EditPart) childEditPart).setLabel(getPrimaryShape().getFigureProjectFigure_ocl_ia());
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean removeFixedChild(EditPart childEditPart) {
+ if (childEditPart instanceof ProjectNameEditPart) {
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel3EditPart) {
+ return true;
+ }
+ if (childEditPart instanceof WrappingLabel4EditPart) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addChildVisual(EditPart childEditPart, int index) {
+ if (addFixedChild(childEditPart)) {
+ return;
+ }
+ super.addChildVisual(childEditPart, -1);
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeChildVisual(EditPart childEditPart) {
+ if (removeFixedChild(childEditPart)) {
+ return;
+ }
+ super.removeChildVisual(childEditPart);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
+ return getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected NodeFigure createNodePlate() {
+ DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(400, 50);
+ return result;
+ }
+
+ /**
+ * Creates figure for this edit part.
+ *
+ * Body of this method does not depend on settings in generation model
+ * so you may safely remove <i>generated</i> tag and modify it.
+ *
+ * @generated
+ */
+ protected NodeFigure createNodeFigure() {
+ NodeFigure figure = createNodePlate();
+ figure.setLayoutManager(new StackLayout());
+ IFigure shape = createNodeShape();
+ figure.add(shape);
+ contentPane = setupContentPane(shape);
+ return figure;
+ }
+
+ /**
+ * Default implementation treats passed figure as content pane.
+ * Respects layout one may have set for generated figure.
+ * @param nodeShape instance of generated figure class
+ * @generated
+ */
+ protected IFigure setupContentPane(IFigure nodeShape) {
+ if (nodeShape.getLayoutManager() == null) {
+ ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
+ layout.setSpacing(5);
+ nodeShape.setLayoutManager(layout);
+ }
+ return nodeShape; // use nodeShape itself as contentPane
+ }
+
+ /**
+ * @generated
+ */
+ public IFigure getContentPane() {
+ if (contentPane != null) {
+ return contentPane;
+ }
+ return super.getContentPane();
+ }
+
+ /**
+ * @generated
+ */
+ protected void setForegroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setForegroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setBackgroundColor(Color color) {
+ if (primaryShape != null) {
+ primaryShape.setBackgroundColor(color);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineWidth(int width) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineWidth(width);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLineType(int style) {
+ if (primaryShape instanceof Shape) {
+ ((Shape) primaryShape).setLineStyle(style);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public EditPart getPrimaryChildEditPart() {
+ return getChildBySemanticHint(TOEVisualIDRegistry.getType(ProjectNameEditPart.VISUAL_ID));
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMARelTypesOnTarget() {
+ ArrayList<IElementType> types = new ArrayList<IElementType>(2);
+ types.add(TOEElementTypes.ManagerLeads_4002);
+ types.add(TOEElementTypes.Contribution_4003);
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public List<IElementType> getMATypesForSource(IElementType relationshipType) {
+ LinkedList<IElementType> types = new LinkedList<IElementType>();
+ if (relationshipType == TOEElementTypes.ManagerLeads_4002) {
+ types.add(TOEElementTypes.Manager_2004);
+ } else if (relationshipType == TOEElementTypes.Contribution_4003) {
+ types.add(TOEElementTypes.Employee_2001);
+ types.add(TOEElementTypes.Manager_2004);
+ types.add(TOEElementTypes.Employee_3001);
+ }
+ return types;
+ }
+
+ /**
+ * @generated
+ */
+ public class ProjectFigure extends RoundedRectangle {
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureProjectFigure_name;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureProjectFigure_ocl_gmf;
+
+ /**
+ * @generated
+ */
+ private WrappingLabel fFigureProjectFigure_ocl_ia;
+
+ /**
+ * @generated
+ */
+ public ProjectFigure() {
+
+ BorderLayout layoutThis = new BorderLayout();
+ layoutThis.setHorizontalSpacing(4);// TODO mapMode?
+ layoutThis.setVerticalSpacing(4);
+ this.setLayoutManager(layoutThis);
+
+ this.setCornerDimensions(new Dimension(getMapMode().DPtoLP(12), getMapMode().DPtoLP(12)));
+ this.setLineWidth(2);
+ this.setForegroundColor(ColorConstants.green);
+
+ this.setBorder(new MarginBorder(getMapMode().DPtoLP(12), getMapMode().DPtoLP(12), getMapMode().DPtoLP(12), getMapMode().DPtoLP(12)));
+ createContents();
+ }
+
+ /**
+ * @generated
+ */
+ private void createContents() {
+
+ RectangleFigure projectFigure_name_container0 = new RectangleFigure();
+
+ projectFigure_name_container0.setOutline(false);
+
+ this.add(projectFigure_name_container0, BorderLayout.TOP);
+
+ ToolbarLayout layoutProjectFigure_name_container0 = new ToolbarLayout();
+ layoutProjectFigure_name_container0.setStretchMinorAxis(false);
+ layoutProjectFigure_name_container0.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutProjectFigure_name_container0.setSpacing(5);
+ layoutProjectFigure_name_container0.setVertical(true);
+
+ projectFigure_name_container0.setLayoutManager(layoutProjectFigure_name_container0);
+
+ fFigureProjectFigure_name = new WrappingLabel();
+
+ fFigureProjectFigure_name.setAlignment(PositionConstants.CENTER);
+
+ fFigureProjectFigure_name.setBorder(new MarginBorder(getMapMode().DPtoLP(3), getMapMode().DPtoLP(10), getMapMode().DPtoLP(3), getMapMode().DPtoLP(10)));
+
+ projectFigure_name_container0.add(fFigureProjectFigure_name);
+
+ RectangleFigure projectFigure_content_pane0 = new RectangleFigure();
+
+ projectFigure_content_pane0.setOutline(false);
+
+ this.add(projectFigure_content_pane0, BorderLayout.CENTER);
+
+ ToolbarLayout layoutProjectFigure_content_pane0 = new ToolbarLayout();
+ layoutProjectFigure_content_pane0.setStretchMinorAxis(false);
+ layoutProjectFigure_content_pane0.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
+
+ layoutProjectFigure_content_pane0.setSpacing(5);
+ layoutProjectFigure_content_pane0.setVertical(true);
+
+ projectFigure_content_pane0.setLayoutManager(layoutProjectFigure_content_pane0);
+
+ fFigureProjectFigure_ocl_gmf = new WrappingLabel();
+
+ fFigureProjectFigure_ocl_gmf.setText("<gmf>");
+
+ fFigureProjectFigure_ocl_gmf.setBorder(new MarginBorder(getMapMode().DPtoLP(5), getMapMode().DPtoLP(10), getMapMode().DPtoLP(5), getMapMode().DPtoLP(10)));
+
+ projectFigure_content_pane0.add(fFigureProjectFigure_ocl_gmf);
+
+ fFigureProjectFigure_ocl_ia = new WrappingLabel();
+
+ fFigureProjectFigure_ocl_ia.setText("<ia>");
+
+ fFigureProjectFigure_ocl_ia.setBorder(new MarginBorder(getMapMode().DPtoLP(5), getMapMode().DPtoLP(10), getMapMode().DPtoLP(5), getMapMode().DPtoLP(10)));
+
+ projectFigure_content_pane0.add(fFigureProjectFigure_ocl_ia);
+
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureProjectFigure_name() {
+ return fFigureProjectFigure_name;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureProjectFigure_ocl_gmf() {
+ return fFigureProjectFigure_ocl_gmf;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getFigureProjectFigure_ocl_ia() {
+ return fFigureProjectFigure_ocl_ia;
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectNameEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectNameEditPart.java
new file mode 100644
index 000000000..beee07eec
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/ProjectNameEditPart.java
@@ -0,0 +1,534 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class ProjectNameEditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5009;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private List<?> parserElements;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public ProjectNameEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return getParser() != null;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Project_2003, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ProjectNameEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ if (getParser() instanceof ISemanticParser) {
+ EObject element = resolveSemanticElement();
+ parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element);
+ for (int i = 0; i < parserElements.size(); i++) {
+ addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$
+ }
+ } else {
+ super.addSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ if (parserElements != null) {
+ for (int i = 0; i < parserElements.size(); i++) {
+ removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
+ }
+ } else {
+ super.removeSemanticListeners();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/TOEEditPartFactory.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/TOEEditPartFactory.java
new file mode 100644
index 000000000..b58e43af3
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/TOEEditPartFactory.java
@@ -0,0 +1,212 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import org.eclipse.draw2d.FigureUtilities;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @generated
+ */
+public class TOEEditPartFactory implements EditPartFactory {
+
+ /**
+ * @generated
+ */
+ public EditPart createEditPart(EditPart context, Object model) {
+ if (model instanceof View) {
+ View view = (View) model;
+ switch (TOEVisualIDRegistry.getVisualID(view)) {
+
+ case AllHolderEditPart.VISUAL_ID:
+ return new AllHolderEditPart(view);
+
+ case EmployeeEditPart.VISUAL_ID:
+ return new EmployeeEditPart(view);
+
+ case EmployeeNameEditPart.VISUAL_ID:
+ return new EmployeeNameEditPart(view);
+
+ case DepartmentEditPart.VISUAL_ID:
+ return new DepartmentEditPart(view);
+
+ case DepartmentNameEditPart.VISUAL_ID:
+ return new DepartmentNameEditPart(view);
+
+ case WrappingLabelEditPart.VISUAL_ID:
+ return new WrappingLabelEditPart(view);
+
+ case WrappingLabel2EditPart.VISUAL_ID:
+ return new WrappingLabel2EditPart(view);
+
+ case ProjectEditPart.VISUAL_ID:
+ return new ProjectEditPart(view);
+
+ case ProjectNameEditPart.VISUAL_ID:
+ return new ProjectNameEditPart(view);
+
+ case WrappingLabel3EditPart.VISUAL_ID:
+ return new WrappingLabel3EditPart(view);
+
+ case WrappingLabel4EditPart.VISUAL_ID:
+ return new WrappingLabel4EditPart(view);
+
+ case ManagerEditPart.VISUAL_ID:
+ return new ManagerEditPart(view);
+
+ case ManagerNameEditPart.VISUAL_ID:
+ return new ManagerNameEditPart(view);
+
+ case Employee2EditPart.VISUAL_ID:
+ return new Employee2EditPart(view);
+
+ case EmployeeName2EditPart.VISUAL_ID:
+ return new EmployeeName2EditPart(view);
+
+ case Department2EditPart.VISUAL_ID:
+ return new Department2EditPart(view);
+
+ case DepartmentName2EditPart.VISUAL_ID:
+ return new DepartmentName2EditPart(view);
+
+ case WrappingLabel5EditPart.VISUAL_ID:
+ return new WrappingLabel5EditPart(view);
+
+ case WrappingLabel6EditPart.VISUAL_ID:
+ return new WrappingLabel6EditPart(view);
+
+ case DepartmentDepartment_staffEditPart.VISUAL_ID:
+ return new DepartmentDepartment_staffEditPart(view);
+
+ case DepartmentDepartment_staff2EditPart.VISUAL_ID:
+ return new DepartmentDepartment_staff2EditPart(view);
+
+ case ManagerManagedDepartmentEditPart.VISUAL_ID:
+ return new ManagerManagedDepartmentEditPart(view);
+
+ case ManagerLeadsEditPart.VISUAL_ID:
+ return new ManagerLeadsEditPart(view);
+
+ case ContributionEditPart.VISUAL_ID:
+ return new ContributionEditPart(view);
+
+ }
+ }
+ return createUnrecognizedEditPart(context, model);
+ }
+
+ /**
+ * @generated
+ */
+ private EditPart createUnrecognizedEditPart(EditPart context, Object model) {
+ // Handle creation of unrecognized child node EditParts here
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ public static CellEditorLocator getTextCellEditorLocator(ITextAwareEditPart source) {
+ if (source.getFigure() instanceof WrappingLabel)
+ return new TextCellEditorLocator((WrappingLabel) source.getFigure());
+ else {
+ return new LabelCellEditorLocator((Label) source.getFigure());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ static private class TextCellEditorLocator implements CellEditorLocator {
+
+ /**
+ * @generated
+ */
+ private WrappingLabel wrapLabel;
+
+ /**
+ * @generated
+ */
+ public TextCellEditorLocator(WrappingLabel wrapLabel) {
+ this.wrapLabel = wrapLabel;
+ }
+
+ /**
+ * @generated
+ */
+ public WrappingLabel getWrapLabel() {
+ return wrapLabel;
+ }
+
+ /**
+ * @generated
+ */
+ public void relocate(CellEditor celleditor) {
+ Control control = (Control) celleditor.getControl();
+ Rectangle rect = getWrapLabel().getTextBounds().getCopy();
+ getWrapLabel().translateToAbsolute(rect);
+ if (!control.getFont().isDisposed()) {
+ if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) {
+ rect.setSize(new Dimension(control.computeSize(rect.width, SWT.DEFAULT)));
+ } else {
+ int avr = FigureUtilities.getFontMetrics(control.getFont()).getAverageCharWidth();
+ rect.setSize(new Dimension(control.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
+ }
+ }
+ if (!rect.equals(new Rectangle(control.getBounds()))) {
+ control.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private static class LabelCellEditorLocator implements CellEditorLocator {
+
+ /**
+ * @generated
+ */
+ private Label label;
+
+ /**
+ * @generated
+ */
+ public LabelCellEditorLocator(Label label) {
+ this.label = label;
+ }
+
+ /**
+ * @generated
+ */
+ public Label getLabel() {
+ return label;
+ }
+
+ /**
+ * @generated
+ */
+ public void relocate(CellEditor celleditor) {
+ Control control = (Control) celleditor.getControl();
+ Rectangle rect = getLabel().getTextBounds().getCopy();
+ getLabel().translateToAbsolute(rect);
+ if (!control.getFont().isDisposed()) {
+ int avr = FigureUtilities.getFontMetrics(control.getFont()).getAverageCharWidth();
+ rect.setSize(new Dimension(control.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
+ }
+ if (!rect.equals(new Rectangle(control.getBounds()))) {
+ control.setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+ }
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel2EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel2EditPart.java
new file mode 100644
index 000000000..84882ef97
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel2EditPart.java
@@ -0,0 +1,549 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class WrappingLabel2EditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5008;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator myOclRegistrator;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public WrappingLabel2EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Department_2002, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.WrappingLabel2EditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ OclTracker tracker = getTracker();
+ tracker.initialize(resolveSemanticElement());
+ tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ getTracker().uninstallListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker getTracker() {
+ return ((HasOclTracker) getParser()).getOclTracker();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator getOclRegistrator() {
+ if (myOclRegistrator == null) {
+ myOclRegistrator = new OclTracker.Registrator() {
+
+ @Override
+ public void registerListener(String filterId, NotificationListener listener, EObject element) {
+ addListenerFilter(filterId, listener, element);
+ }
+
+ @Override
+ public void unregisterListener(String filterId) {
+ removeListenerFilter(filterId);
+ }
+ };
+ }
+ return myOclRegistrator;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel3EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel3EditPart.java
new file mode 100644
index 000000000..f6acc5a8c
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel3EditPart.java
@@ -0,0 +1,553 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class WrappingLabel3EditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5010;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator myOclRegistrator;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public WrappingLabel3EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Project_2003, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.WrappingLabel3EditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ OclTracker tracker = getTracker();
+ tracker.initialize(resolveSemanticElement());
+ tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ getTracker().uninstallListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker getTracker() {
+ return ((HasOclTracker) getParser()).getOclTracker();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator getOclRegistrator() {
+ if (myOclRegistrator == null) {
+ myOclRegistrator = new OclTracker.Registrator() {
+
+ @Override
+ public void registerListener(String filterId, NotificationListener listener, EObject element) {
+ addListenerFilter(filterId, listener, element);
+ }
+
+ @Override
+ public void unregisterListener(String filterId) {
+ removeListenerFilter(filterId);
+ }
+ };
+ }
+ return myOclRegistrator;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel4EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel4EditPart.java
new file mode 100644
index 000000000..504d20511
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel4EditPart.java
@@ -0,0 +1,553 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class WrappingLabel4EditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5011;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator myOclRegistrator;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public WrappingLabel4EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ EObject parserElement = getParserElement();
+ if (parserElement == null) {
+ return null;
+ }
+ return TOEElementTypes.getImage(parserElement.eClass());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Project_2003, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.WrappingLabel4EditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ OclTracker tracker = getTracker();
+ tracker.initialize(resolveSemanticElement());
+ tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ getTracker().uninstallListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker getTracker() {
+ return ((HasOclTracker) getParser()).getOclTracker();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator getOclRegistrator() {
+ if (myOclRegistrator == null) {
+ myOclRegistrator = new OclTracker.Registrator() {
+
+ @Override
+ public void registerListener(String filterId, NotificationListener listener, EObject element) {
+ addListenerFilter(filterId, listener, element);
+ }
+
+ @Override
+ public void unregisterListener(String filterId) {
+ removeListenerFilter(filterId);
+ }
+ };
+ }
+ return myOclRegistrator;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel5EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel5EditPart.java
new file mode 100644
index 000000000..e6af1cb06
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel5EditPart.java
@@ -0,0 +1,549 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class WrappingLabel5EditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5004;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator myOclRegistrator;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public WrappingLabel5EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Department_3002, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.WrappingLabel5EditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ OclTracker tracker = getTracker();
+ tracker.initialize(resolveSemanticElement());
+ tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ getTracker().uninstallListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker getTracker() {
+ return ((HasOclTracker) getParser()).getOclTracker();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator getOclRegistrator() {
+ if (myOclRegistrator == null) {
+ myOclRegistrator = new OclTracker.Registrator() {
+
+ @Override
+ public void registerListener(String filterId, NotificationListener listener, EObject element) {
+ addListenerFilter(filterId, listener, element);
+ }
+
+ @Override
+ public void unregisterListener(String filterId) {
+ removeListenerFilter(filterId);
+ }
+ };
+ }
+ return myOclRegistrator;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel6EditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel6EditPart.java
new file mode 100644
index 000000000..75c139b51
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabel6EditPart.java
@@ -0,0 +1,549 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class WrappingLabel6EditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5005;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator myOclRegistrator;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public WrappingLabel6EditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Department_3002, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.WrappingLabel6EditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ OclTracker tracker = getTracker();
+ tracker.initialize(resolveSemanticElement());
+ tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ getTracker().uninstallListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker getTracker() {
+ return ((HasOclTracker) getParser()).getOclTracker();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator getOclRegistrator() {
+ if (myOclRegistrator == null) {
+ myOclRegistrator = new OclTracker.Registrator() {
+
+ @Override
+ public void registerListener(String filterId, NotificationListener listener, EObject element) {
+ addListenerFilter(filterId, listener, element);
+ }
+
+ @Override
+ public void unregisterListener(String filterId) {
+ removeListenerFilter(filterId);
+ }
+ };
+ }
+ return myOclRegistrator;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabelEditPart.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabelEditPart.java
new file mode 100644
index 000000000..66a8f60a7
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/parts/WrappingLabelEditPart.java
@@ -0,0 +1,549 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.RunnableWithResult;
+import org.eclipse.gef.AccessibleEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DirectEditRequest;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.TOETextSelectionEditPolicy;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEParserProvider;
+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.common.ui.services.parser.ParserOptions;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.gmf.runtime.notation.FontStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.directedit.TextDirectEditManager2;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.HasOclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @generated
+ */
+public class WrappingLabelEditPart extends CompartmentEditPart implements ITextAwareEditPart {
+
+ /**
+ * @generated
+ */
+ public static final int VISUAL_ID = 5007;
+
+ /**
+ * @generated
+ */
+ private DirectEditManager manager;
+
+ /**
+ * @generated
+ */
+ private IParser parser;
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator myOclRegistrator;
+
+ /**
+ * @generated
+ */
+ private String defaultText;
+
+ /**
+ * @generated
+ */
+ public WrappingLabelEditPart(View view) {
+ super(view);
+ }
+
+ /**
+ * @generated
+ */
+ protected void createDefaultEditPolicies() {
+ super.createDefaultEditPolicies();
+ installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new TOETextSelectionEditPolicy());
+ installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AllHolderEditPart.NodeLabelDragPolicy());
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelTextHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getText();
+ } else {
+ return ((Label) figure).getText();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelTextHelper(IFigure figure, String text) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setText(text);
+ } else {
+ ((Label) figure).setText(text);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIconHelper(IFigure figure) {
+ if (figure instanceof WrappingLabel) {
+ return ((WrappingLabel) figure).getIcon();
+ } else {
+ return ((Label) figure).getIcon();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setLabelIconHelper(IFigure figure, Image icon) {
+ if (figure instanceof WrappingLabel) {
+ ((WrappingLabel) figure).setIcon(icon);
+ } else {
+ ((Label) figure).setIcon(icon);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabel(WrappingLabel figure) {
+ unregisterVisuals();
+ setFigure(figure);
+ defaultText = getLabelTextHelper(figure);
+ registerVisuals();
+ refreshVisuals();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getModelChildren() {
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @generated
+ */
+ public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected EObject getParserElement() {
+ return resolveSemanticElement();
+ }
+
+ /**
+ * @generated
+ */
+ protected Image getLabelIcon() {
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected String getLabelText() {
+ String text = null;
+ EObject parserElement = getParserElement();
+ if (parserElement != null && getParser() != null) {
+ text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
+ }
+ if (text == null || text.length() == 0) {
+ text = defaultText;
+ }
+ return text;
+ }
+
+ /**
+ * @generated
+ */
+ public void setLabelText(String text) {
+ setLabelTextHelper(getFigure(), text);
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ public String getEditText() {
+ if (getParserElement() == null || getParser() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isEditable() {
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ public ICellEditorValidator getEditTextValidator() {
+ return new ICellEditorValidator() {
+
+ public String isValid(final Object value) {
+ if (value instanceof String) {
+ final EObject element = getParserElement();
+ final IParser parser = getParser();
+ try {
+ IParserEditStatus valid = (IParserEditStatus) getEditingDomain().runExclusive(new RunnableWithResult.Impl<IParserEditStatus>() {
+
+ public void run() {
+ setResult(parser.isValidEditString(new EObjectAdapter(element), (String) value));
+ }
+ });
+ return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
+ } catch (InterruptedException ie) {
+ ie.printStackTrace();
+ }
+ }
+
+ // shouldn't get here
+ return null;
+ }
+ };
+ }
+
+ /**
+ * @generated
+ */
+ public IContentAssistProcessor getCompletionProcessor() {
+ if (getParserElement() == null || getParser() == null) {
+ return null;
+ }
+ return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
+ }
+
+ /**
+ * @generated
+ */
+ public ParserOptions getParserOptions() {
+ return ParserOptions.NONE;
+ }
+
+ /**
+ * @generated
+ */
+ public IParser getParser() {
+ if (parser == null) {
+ parser = TOEParserProvider.getParser(TOEElementTypes.Department_2002, getParserElement(),
+ TOEVisualIDRegistry.getType(org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.WrappingLabelEditPart.VISUAL_ID));
+ }
+ return parser;
+ }
+
+ /**
+ * @generated
+ */
+ protected DirectEditManager getManager() {
+ if (manager == null) {
+ setManager(new TextDirectEditManager2(this, null, TOEEditPartFactory.getTextCellEditorLocator(this)));
+ }
+ return manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void setManager(DirectEditManager manager) {
+ this.manager = manager;
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit() {
+ getManager().show();
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEdit(Point eventLocation) {
+ if (getManager().getClass() == TextDirectEditManager2.class) {
+ ((TextDirectEditManager2) getManager()).show(eventLocation.getSWTPoint());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ private void performDirectEdit(char initialCharacter) {
+ if (getManager() instanceof TextDirectEditManager) {
+ ((TextDirectEditManager) getManager()).show(initialCharacter);
+ } else //
+ if (getManager() instanceof TextDirectEditManager2) {
+ ((TextDirectEditManager2) getManager()).show(initialCharacter);
+ } else //
+ {
+ performDirectEdit();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void performDirectEditRequest(Request request) {
+ final Request theRequest = request;
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if (isActive() && isEditable()) {
+ if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character) theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
+ DirectEditRequest editRequest = (DirectEditRequest) theRequest;
+ performDirectEdit(editRequest.getLocation());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshVisuals() {
+ super.refreshVisuals();
+ refreshLabel();
+ refreshFont();
+ refreshFontColor();
+ refreshUnderline();
+ refreshStrikeThrough();
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshLabel() {
+ setLabelTextHelper(getFigure(), getLabelText());
+ setLabelIconHelper(getFigure(), getLabelIcon());
+ Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
+ if (pdEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) pdEditPolicy).refreshFeedback();
+ }
+ Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
+ if (sfEditPolicy instanceof TOETextSelectionEditPolicy) {
+ ((TOETextSelectionEditPolicy) sfEditPolicy).refreshFeedback();
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshUnderline() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshStrikeThrough() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null && getFigure() instanceof WrappingLabel) {
+ ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough());
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshFont() {
+ FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
+ if (style != null) {
+ FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL));
+ setFont(fontData);
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected void setFontColor(Color color) {
+ getFigure().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ protected void addSemanticListeners() {
+ OclTracker tracker = getTracker();
+ tracker.initialize(resolveSemanticElement());
+ tracker.installListeners(getEditingDomain(), this, getOclRegistrator());
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeSemanticListeners() {
+ getTracker().uninstallListeners();
+ }
+
+ /**
+ * @generated
+ */
+ protected AccessibleEditPart getAccessibleEditPart() {
+ if (accessibleEP == null) {
+ accessibleEP = new AccessibleGraphicalEditPart() {
+
+ public void getName(AccessibleEvent e) {
+ e.result = getLabelTextHelper(getFigure());
+ }
+ };
+ }
+ return accessibleEP;
+ }
+
+ /**
+ * @generated
+ */
+ private View getFontStyleOwnerView() {
+ return getPrimaryView();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker getTracker() {
+ return ((HasOclTracker) getParser()).getOclTracker();
+ }
+
+ /**
+ * @generated
+ */
+ private OclTracker.Registrator getOclRegistrator() {
+ if (myOclRegistrator == null) {
+ myOclRegistrator = new OclTracker.Registrator() {
+
+ @Override
+ public void registerListener(String filterId, NotificationListener listener, EObject element) {
+ addListenerFilter(filterId, listener, element);
+ }
+
+ @Override
+ public void unregisterListener(String filterId) {
+ removeListenerFilter(filterId);
+ }
+ };
+ }
+ return myOclRegistrator;
+ }
+
+ /**
+ * @generated
+ */
+ protected void addNotationalListeners() {
+ super.addNotationalListeners();
+ addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void removeNotationalListeners() {
+ super.removeNotationalListeners();
+ removeListenerFilter("PrimaryView"); //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ protected void handleNotificationEvent(Notification event) {
+ Object feature = event.getFeature();
+ if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) {
+ Integer c = (Integer) event.getNewValue();
+ setFontColor(DiagramColorRegistry.getInstance().getColor(c));
+ } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) {
+ refreshUnderline();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) {
+ refreshStrikeThrough();
+ } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature)
+ || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
+ refreshFont();
+ } else {
+ if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) {
+ refreshLabel();
+ }
+ if (getParser() instanceof ISemanticParser) {
+ ISemanticParser modelParser = (ISemanticParser) getParser();
+ if (modelParser.areSemanticElementsAffected(null, event)) {
+ removeSemanticListeners();
+ if (resolveSemanticElement() != null) {
+ addSemanticListeners();
+ }
+ refreshLabel();
+ }
+ }
+ }
+ super.handleNotificationEvent(event);
+ }
+
+ /**
+ * @generated
+ */
+ protected IFigure createFigure() {
+ // Parent should assign one using setLabel() method
+ return null;
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderCanonicalEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderCanonicalEditPolicy.java
new file mode 100644
index 000000000..8eaba574b
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderCanonicalEditPolicy.java
@@ -0,0 +1,360 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEPackage;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.AllHolderEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ContributionEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Department2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ProjectEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramUpdater;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOELinkDescriptor;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOENodeDescriptor;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilityCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+* @generated
+*/
+public class AllHolderCanonicalEditPolicy extends CanonicalEditPolicy {
+
+ /**
+ * @generated
+ */
+ protected void refreshOnActivate() {
+ // Need to activate editpart children before invoking the canonical refresh for EditParts to add event listeners
+ List<?> c = getHost().getChildren();
+ for (int i = 0; i < c.size(); i++) {
+ ((EditPart) c.get(i)).activate();
+ }
+ super.refreshOnActivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected EStructuralFeature getFeatureToSynchronize() {
+ return TOEPackage.eINSTANCE.getAllHolder_All();
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getSemanticChildrenList() {
+ View viewObject = (View) getHost().getModel();
+ LinkedList<EObject> result = new LinkedList<EObject>();
+ List<TOENodeDescriptor> childDescriptors = TOEDiagramUpdater.getAllHolder_1000SemanticChildren(viewObject);
+ for (TOENodeDescriptor d : childDescriptors) {
+ result.add(d.getModelElement());
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) {
+ return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement());
+ }
+
+ /**
+ * @generated
+ */
+ private boolean isMyDiagramElement(View view) {
+ int visualID = TOEVisualIDRegistry.getVisualID(view);
+ switch (visualID) {
+ case EmployeeEditPart.VISUAL_ID:
+ case DepartmentEditPart.VISUAL_ID:
+ case ProjectEditPart.VISUAL_ID:
+ case ManagerEditPart.VISUAL_ID:
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSemantic() {
+ if (resolveSemanticElement() == null) {
+ return;
+ }
+ LinkedList<IAdaptable> createdViews = new LinkedList<IAdaptable>();
+ List<TOENodeDescriptor> childDescriptors = TOEDiagramUpdater.getAllHolder_1000SemanticChildren((View) getHost().getModel());
+ LinkedList<View> orphaned = new LinkedList<View>();
+ // we care to check only views we recognize as ours
+ LinkedList<View> knownViewChildren = new LinkedList<View>();
+ for (View v : getViewChildren()) {
+ if (isMyDiagramElement(v)) {
+ knownViewChildren.add(v);
+ }
+ }
+ // alternative to #cleanCanonicalSemanticChildren(getViewChildren(), semanticChildren)
+ //
+ // iteration happens over list of desired semantic elements, trying to find best matching View, while original CEP
+ // iterates views, potentially losing view (size/bounds) information - i.e. if there are few views to reference same EObject, only last one
+ // to answer isOrphaned == true will be used for the domain element representation, see #cleanCanonicalSemanticChildren()
+ for (Iterator<TOENodeDescriptor> descriptorsIterator = childDescriptors.iterator(); descriptorsIterator.hasNext();) {
+ TOENodeDescriptor next = descriptorsIterator.next();
+ String hint = TOEVisualIDRegistry.getType(next.getVisualID());
+ LinkedList<View> perfectMatch = new LinkedList<View>(); // both semanticElement and hint match that of NodeDescriptor
+ for (View childView : getViewChildren()) {
+ EObject semanticElement = childView.getElement();
+ if (next.getModelElement().equals(semanticElement)) {
+ if (hint.equals(childView.getType())) {
+ perfectMatch.add(childView);
+ // actually, can stop iteration over view children here, but
+ // may want to use not the first view but last one as a 'real' match (the way original CEP does
+ // with its trick with viewToSemanticMap inside #cleanCanonicalSemanticChildren
+ }
+ }
+ }
+ if (perfectMatch.size() > 0) {
+ descriptorsIterator.remove(); // precise match found no need to create anything for the NodeDescriptor
+ // use only one view (first or last?), keep rest as orphaned for further consideration
+ knownViewChildren.remove(perfectMatch.getFirst());
+ }
+ }
+ // those left in knownViewChildren are subject to removal - they are our diagram elements we didn't find match to,
+ // or those we have potential matches to, and thus need to be recreated, preserving size/location information.
+ orphaned.addAll(knownViewChildren);
+ //
+ ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(childDescriptors.size());
+ for (TOENodeDescriptor next : childDescriptors) {
+ String hint = TOEVisualIDRegistry.getType(next.getVisualID());
+ IAdaptable elementAdapter = new CanonicalElementAdapter(next.getModelElement(), hint);
+ CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(elementAdapter, Node.class, hint, ViewUtil.APPEND, false, host().getDiagramPreferencesHint());
+ viewDescriptors.add(descriptor);
+ }
+
+ boolean changed = deleteViews(orphaned.iterator());
+ //
+ CreateViewRequest request = getCreateViewRequest(viewDescriptors);
+ Command cmd = getCreateViewCommand(request);
+ if (cmd != null && cmd.canExecute()) {
+ SetViewMutabilityCommand.makeMutable(new EObjectAdapter(host().getNotationView())).execute();
+ executeCommand(cmd);
+ @SuppressWarnings("unchecked")
+ List<IAdaptable> nl = (List<IAdaptable>) request.getNewObject();
+ createdViews.addAll(nl);
+ }
+ if (changed || createdViews.size() > 0) {
+ postProcessRefreshSemantic(createdViews);
+ }
+
+ Collection<IAdaptable> createdConnectionViews = refreshConnections();
+
+ if (createdViews.size() > 1) {
+ // perform a layout of the container
+ DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
+ executeCommand(new ICommandProxy(layoutCmd));
+ }
+
+ createdViews.addAll(createdConnectionViews);
+
+ makeViewsImmutable(createdViews);
+ }
+
+ /**
+ * @generated
+ */
+ private Collection<IAdaptable> refreshConnections() {
+ Map<EObject, View> domain2NotationMap = new HashMap<EObject, View>();
+ Collection<TOELinkDescriptor> linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap);
+ Collection existingLinks = new LinkedList(getDiagram().getEdges());
+ for (Iterator linksIterator = existingLinks.iterator(); linksIterator.hasNext();) {
+ Edge nextDiagramLink = (Edge) linksIterator.next();
+ int diagramLinkVisualID = TOEVisualIDRegistry.getVisualID(nextDiagramLink);
+ if (diagramLinkVisualID == -1) {
+ if (nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) {
+ linksIterator.remove();
+ }
+ continue;
+ }
+ EObject diagramLinkObject = nextDiagramLink.getElement();
+ EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
+ EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
+ for (Iterator<TOELinkDescriptor> linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext();) {
+ TOELinkDescriptor nextLinkDescriptor = linkDescriptorsIterator.next();
+ if (diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination()
+ && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) {
+ linksIterator.remove();
+ linkDescriptorsIterator.remove();
+ break;
+ }
+ }
+ }
+ deleteViews(existingLinks.iterator());
+ return createConnections(linkDescriptors, domain2NotationMap);
+ }
+
+ /**
+ * @generated
+ */
+ private Collection<TOELinkDescriptor> collectAllLinks(View view, Map<EObject, View> domain2NotationMap) {
+ if (!AllHolderEditPart.MODEL_ID.equals(TOEVisualIDRegistry.getModelID(view))) {
+ return Collections.emptyList();
+ }
+ LinkedList<TOELinkDescriptor> result = new LinkedList<TOELinkDescriptor>();
+ switch (TOEVisualIDRegistry.getVisualID(view)) {
+ case AllHolderEditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getAllHolder_1000ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ case EmployeeEditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getEmployee_2001ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ case DepartmentEditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getDepartment_2002ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ case ProjectEditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getProject_2003ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ case ManagerEditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getManager_2004ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ case Employee2EditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getEmployee_3001ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ case Department2EditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getDepartment_3002ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ case ContributionEditPart.VISUAL_ID: {
+ if (!domain2NotationMap.containsKey(view.getElement())) {
+ result.addAll(TOEDiagramUpdater.getContribution_4003ContainedLinks(view));
+ }
+ if (!domain2NotationMap.containsKey(view.getElement()) || view.getEAnnotation("Shortcut") == null) { //$NON-NLS-1$
+ domain2NotationMap.put(view.getElement(), view);
+ }
+ break;
+ }
+ }
+ for (Iterator children = view.getChildren().iterator(); children.hasNext();) {
+ result.addAll(collectAllLinks((View) children.next(), domain2NotationMap));
+ }
+ for (Iterator edges = view.getSourceEdges().iterator(); edges.hasNext();) {
+ result.addAll(collectAllLinks((View) edges.next(), domain2NotationMap));
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ private Collection<IAdaptable> createConnections(Collection<TOELinkDescriptor> linkDescriptors, Map<EObject, View> domain2NotationMap) {
+ LinkedList<IAdaptable> adapters = new LinkedList<IAdaptable>();
+ for (TOELinkDescriptor nextLinkDescriptor : linkDescriptors) {
+ EditPart sourceEditPart = getEditPart(nextLinkDescriptor.getSource(), domain2NotationMap);
+ EditPart targetEditPart = getEditPart(nextLinkDescriptor.getDestination(), domain2NotationMap);
+ if (sourceEditPart == null || targetEditPart == null) {
+ continue;
+ }
+ CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor(nextLinkDescriptor.getSemanticAdapter(),
+ TOEVisualIDRegistry.getType(nextLinkDescriptor.getVisualID()), ViewUtil.APPEND, false, ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint());
+ CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(descriptor);
+ ccr.setType(RequestConstants.REQ_CONNECTION_START);
+ ccr.setSourceEditPart(sourceEditPart);
+ sourceEditPart.getCommand(ccr);
+ ccr.setTargetEditPart(targetEditPart);
+ ccr.setType(RequestConstants.REQ_CONNECTION_END);
+ Command cmd = targetEditPart.getCommand(ccr);
+ if (cmd != null && cmd.canExecute()) {
+ executeCommand(cmd);
+ IAdaptable viewAdapter = (IAdaptable) ccr.getNewObject();
+ if (viewAdapter != null) {
+ adapters.add(viewAdapter);
+ }
+ }
+ }
+ return adapters;
+ }
+
+ /**
+ * @generated
+ */
+ private EditPart getEditPart(EObject domainModelElement, Map<EObject, View> domain2NotationMap) {
+ View view = (View) domain2NotationMap.get(domainModelElement);
+ if (view != null) {
+ return (EditPart) getHost().getViewer().getEditPartRegistry().get(view);
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ private Diagram getDiagram() {
+ return ((View) getHost().getModel()).getDiagram();
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderItemSemanticEditPolicy.java
new file mode 100644
index 000000000..d0fd4b64d
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/AllHolderItemSemanticEditPolicy.java
@@ -0,0 +1,68 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.DepartmentCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.EmployeeCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ProjectCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.commands.core.commands.DuplicateEObjectsCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DuplicateElementsRequest;
+
+/**
+* @generated
+*/
+public class AllHolderItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public AllHolderItemSemanticEditPolicy() {
+ super(TOEElementTypes.AllHolder_1000);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ if (TOEElementTypes.Employee_2001 == req.getElementType()) {
+ return getGEFWrapper(new EmployeeCreateCommand(req));
+ }
+ if (TOEElementTypes.Department_2002 == req.getElementType()) {
+ return getGEFWrapper(new DepartmentCreateCommand(req));
+ }
+ if (TOEElementTypes.Project_2003 == req.getElementType()) {
+ return getGEFWrapper(new ProjectCreateCommand(req));
+ }
+ if (TOEElementTypes.Manager_2004 == req.getElementType()) {
+ return getGEFWrapper(new ManagerCreateCommand(req));
+ }
+ return super.getCreateCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDuplicateCommand(DuplicateElementsRequest req) {
+ TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
+ return getGEFWrapper(new DuplicateAnythingCommand(editingDomain, req));
+ }
+
+ /**
+ * @generated
+ */
+ private static class DuplicateAnythingCommand extends DuplicateEObjectsCommand {
+
+ /**
+ * @generated
+ */
+ public DuplicateAnythingCommand(TransactionalEditingDomain editingDomain, DuplicateElementsRequest req) {
+ super(editingDomain, req.getLabel(), req.getElementsToBeDuplicated(), req.getAllDuplicatedElementsMap());
+ }
+
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionConnectionPinForeground4003Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionConnectionPinForeground4003Policy.java
new file mode 100644
index 000000000..7b27ce5c8
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionConnectionPinForeground4003Policy.java
@@ -0,0 +1,56 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ContributionEditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+import org.eclipse.ocl.util.Tuple;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class ContributionConnectionPinForeground4003Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ContributionConnectionPinForeground4003Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public ContributionConnectionPinForeground4003Policy() {
+ super();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ Tuple<?, ?> tupleValue = (Tuple<?, ?>) value;
+ Integer red = (Integer) tupleValue.getValue("red");
+ Integer green = (Integer) tupleValue.getValue("green");
+ Integer blue = (Integer) tupleValue.getValue("blue");
+ Color color = new Color(null, red, green, blue);
+ getHostImpl().getPrimaryShape().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ContributionEditPart getHostImpl() {
+ return (ContributionEditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return " let _src : Employee = self.employee in " //
+ + " let _dst : Project = self.project in " //
+ + "if _src.contributions->size() > _dst.contributions->size()\r\nthen Tuple {red: Integer = 0, green: Integer = 255, blue: Integer = 0} \r\nelse Tuple {red: Integer = 0, green: Integer =0, blue: Integer = 255} \r\nendif"; //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionItemSemanticEditPolicy.java
new file mode 100644
index 000000000..690c2305e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ContributionItemSemanticEditPolicy.java
@@ -0,0 +1,27 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+
+/**
+ * @generated
+ */
+public class ContributionItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ContributionItemSemanticEditPolicy() {
+ super(TOEElementTypes.Contribution_4003);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ return getGEFWrapper(new DestroyElementCommand(req));
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Department2ItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Department2ItemSemanticEditPolicy.java
new file mode 100644
index 000000000..b5944b7c9
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Department2ItemSemanticEditPolicy.java
@@ -0,0 +1,159 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerManagedDepartmentCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerManagedDepartmentReorientCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ContributionEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Department2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentDepartment_staff2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerManagedDepartmentEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class Department2ItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public Department2ItemSemanticEditPolicy() {
+ super(TOEElementTypes.Department_3002);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(false);
+ for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(incomingLink) == ManagerManagedDepartmentEditPart.VISUAL_ID) {
+ DestroyReferenceRequest r = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
+ continue;
+ }
+ }
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: false
+ addDestroyChildNodesCommand(cmd);
+ addDestroyShortcutsCommand(cmd, view);
+ // delete host element
+ cmd.add(new DestroyElementCommand(req));
+ } else {
+ cmd.add(new DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (TOEVisualIDRegistry.getVisualID(node)) {
+ case DepartmentDepartment_staff2EditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (TOEVisualIDRegistry.getVisualID(cnode)) {
+ case Employee2EditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(outgoingLink) == ContributionEditPart.VISUAL_ID) {
+ DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+ }
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of cnode as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
+ break;
+ case Department2EditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(incomingLink) == ManagerManagedDepartmentEditPart.VISUAL_ID) {
+ DestroyReferenceRequest r = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
+ continue;
+ }
+ }
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of cnode as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.ManagerManagedDepartment_4001 == req.getElementType()) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.ManagerManagedDepartment_4001 == req.getElementType()) {
+ return getGEFWrapper(new ManagerManagedDepartmentCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * Returns command to reorient EReference based link. New link target or source
+ * should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ManagerManagedDepartmentEditPart.VISUAL_ID:
+ return getGEFWrapper(new ManagerManagedDepartmentReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2CanonicalEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2CanonicalEditPolicy.java
new file mode 100644
index 000000000..41e57c021
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2CanonicalEditPolicy.java
@@ -0,0 +1,172 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEPackage;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Department2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramUpdater;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOENodeDescriptor;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilityCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class DepartmentDepartment_staff2CanonicalEditPolicy extends CanonicalEditPolicy {
+
+ /**
+ * @generated
+ */
+ private Set<EStructuralFeature> myFeaturesToSynchronize;
+
+ /**
+ * @generated
+ */
+ protected void refreshOnActivate() {
+ // Need to activate editpart children before invoking the canonical refresh for EditParts to add event listeners
+ List<?> c = getHost().getChildren();
+ for (int i = 0; i < c.size(); i++) {
+ ((EditPart) c.get(i)).activate();
+ }
+ super.refreshOnActivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected Set getFeaturesToSynchronize() {
+ if (myFeaturesToSynchronize == null) {
+ myFeaturesToSynchronize = new HashSet<EStructuralFeature>();
+ myFeaturesToSynchronize.add(TOEPackage.eINSTANCE.getDepartment_Employees());
+ myFeaturesToSynchronize.add(TOEPackage.eINSTANCE.getDepartment_SubDepartments());
+ }
+ return myFeaturesToSynchronize;
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getSemanticChildrenList() {
+ View viewObject = (View) getHost().getModel();
+ LinkedList<EObject> result = new LinkedList<EObject>();
+ List<TOENodeDescriptor> childDescriptors = TOEDiagramUpdater.getDepartmentDepartment_staff_7002SemanticChildren(viewObject);
+ for (TOENodeDescriptor d : childDescriptors) {
+ result.add(d.getModelElement());
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) {
+ return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement());
+ }
+
+ /**
+ * @generated
+ */
+ private boolean isMyDiagramElement(View view) {
+ int visualID = TOEVisualIDRegistry.getVisualID(view);
+ return visualID == Employee2EditPart.VISUAL_ID || visualID == Department2EditPart.VISUAL_ID;
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSemantic() {
+ if (resolveSemanticElement() == null) {
+ return;
+ }
+ LinkedList<IAdaptable> createdViews = new LinkedList<IAdaptable>();
+ List<TOENodeDescriptor> childDescriptors = TOEDiagramUpdater.getDepartmentDepartment_staff_7002SemanticChildren((View) getHost().getModel());
+ LinkedList<View> orphaned = new LinkedList<View>();
+ // we care to check only views we recognize as ours
+ LinkedList<View> knownViewChildren = new LinkedList<View>();
+ for (View v : getViewChildren()) {
+ if (isMyDiagramElement(v)) {
+ knownViewChildren.add(v);
+ }
+ }
+ // alternative to #cleanCanonicalSemanticChildren(getViewChildren(), semanticChildren)
+ //
+ // iteration happens over list of desired semantic elements, trying to find best matching View, while original CEP
+ // iterates views, potentially losing view (size/bounds) information - i.e. if there are few views to reference same EObject, only last one
+ // to answer isOrphaned == true will be used for the domain element representation, see #cleanCanonicalSemanticChildren()
+ for (Iterator<TOENodeDescriptor> descriptorsIterator = childDescriptors.iterator(); descriptorsIterator.hasNext();) {
+ TOENodeDescriptor next = descriptorsIterator.next();
+ String hint = TOEVisualIDRegistry.getType(next.getVisualID());
+ LinkedList<View> perfectMatch = new LinkedList<View>(); // both semanticElement and hint match that of NodeDescriptor
+ for (View childView : getViewChildren()) {
+ EObject semanticElement = childView.getElement();
+ if (next.getModelElement().equals(semanticElement)) {
+ if (hint.equals(childView.getType())) {
+ perfectMatch.add(childView);
+ // actually, can stop iteration over view children here, but
+ // may want to use not the first view but last one as a 'real' match (the way original CEP does
+ // with its trick with viewToSemanticMap inside #cleanCanonicalSemanticChildren
+ }
+ }
+ }
+ if (perfectMatch.size() > 0) {
+ descriptorsIterator.remove(); // precise match found no need to create anything for the NodeDescriptor
+ // use only one view (first or last?), keep rest as orphaned for further consideration
+ knownViewChildren.remove(perfectMatch.getFirst());
+ }
+ }
+ // those left in knownViewChildren are subject to removal - they are our diagram elements we didn't find match to,
+ // or those we have potential matches to, and thus need to be recreated, preserving size/location information.
+ orphaned.addAll(knownViewChildren);
+ //
+ ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(childDescriptors.size());
+ for (TOENodeDescriptor next : childDescriptors) {
+ String hint = TOEVisualIDRegistry.getType(next.getVisualID());
+ IAdaptable elementAdapter = new CanonicalElementAdapter(next.getModelElement(), hint);
+ CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(elementAdapter, Node.class, hint, ViewUtil.APPEND, false, host().getDiagramPreferencesHint());
+ viewDescriptors.add(descriptor);
+ }
+
+ boolean changed = deleteViews(orphaned.iterator());
+ //
+ CreateViewRequest request = getCreateViewRequest(viewDescriptors);
+ Command cmd = getCreateViewCommand(request);
+ if (cmd != null && cmd.canExecute()) {
+ SetViewMutabilityCommand.makeMutable(new EObjectAdapter(host().getNotationView())).execute();
+ executeCommand(cmd);
+ @SuppressWarnings("unchecked")
+ List<IAdaptable> nl = (List<IAdaptable>) request.getNewObject();
+ createdViews.addAll(nl);
+ }
+ if (changed || createdViews.size() > 0) {
+ postProcessRefreshSemantic(createdViews);
+ }
+ if (createdViews.size() > 1) {
+ // perform a layout of the container
+ DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
+ executeCommand(new ICommandProxy(layoutCmd));
+ }
+
+ makeViewsImmutable(createdViews);
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2ItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2ItemSemanticEditPolicy.java
new file mode 100644
index 000000000..7220b479b
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staff2ItemSemanticEditPolicy.java
@@ -0,0 +1,34 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.Department2CreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.Employee2CreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+
+/**
+* @generated
+*/
+public class DepartmentDepartment_staff2ItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DepartmentDepartment_staff2ItemSemanticEditPolicy() {
+ super(TOEElementTypes.Department_3002);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ if (TOEElementTypes.Employee_3001 == req.getElementType()) {
+ return getGEFWrapper(new Employee2CreateCommand(req));
+ }
+ if (TOEElementTypes.Department_3002 == req.getElementType()) {
+ return getGEFWrapper(new Department2CreateCommand(req));
+ }
+ return super.getCreateCommand(req);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffCanonicalEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffCanonicalEditPolicy.java
new file mode 100644
index 000000000..26b1662f7
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffCanonicalEditPolicy.java
@@ -0,0 +1,172 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.TOEPackage;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Department2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEDiagramUpdater;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOENodeDescriptor;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand;
+import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilityCommand;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
+import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class DepartmentDepartment_staffCanonicalEditPolicy extends CanonicalEditPolicy {
+
+ /**
+ * @generated
+ */
+ private Set<EStructuralFeature> myFeaturesToSynchronize;
+
+ /**
+ * @generated
+ */
+ protected void refreshOnActivate() {
+ // Need to activate editpart children before invoking the canonical refresh for EditParts to add event listeners
+ List<?> c = getHost().getChildren();
+ for (int i = 0; i < c.size(); i++) {
+ ((EditPart) c.get(i)).activate();
+ }
+ super.refreshOnActivate();
+ }
+
+ /**
+ * @generated
+ */
+ protected Set getFeaturesToSynchronize() {
+ if (myFeaturesToSynchronize == null) {
+ myFeaturesToSynchronize = new HashSet<EStructuralFeature>();
+ myFeaturesToSynchronize.add(TOEPackage.eINSTANCE.getDepartment_Employees());
+ myFeaturesToSynchronize.add(TOEPackage.eINSTANCE.getDepartment_SubDepartments());
+ }
+ return myFeaturesToSynchronize;
+ }
+
+ /**
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getSemanticChildrenList() {
+ View viewObject = (View) getHost().getModel();
+ LinkedList<EObject> result = new LinkedList<EObject>();
+ List<TOENodeDescriptor> childDescriptors = TOEDiagramUpdater.getDepartmentDepartment_staff_7001SemanticChildren(viewObject);
+ for (TOENodeDescriptor d : childDescriptors) {
+ result.add(d.getModelElement());
+ }
+ return result;
+ }
+
+ /**
+ * @generated
+ */
+ protected boolean isOrphaned(Collection<EObject> semanticChildren, final View view) {
+ return isMyDiagramElement(view) && !semanticChildren.contains(view.getElement());
+ }
+
+ /**
+ * @generated
+ */
+ private boolean isMyDiagramElement(View view) {
+ int visualID = TOEVisualIDRegistry.getVisualID(view);
+ return visualID == Employee2EditPart.VISUAL_ID || visualID == Department2EditPart.VISUAL_ID;
+ }
+
+ /**
+ * @generated
+ */
+ protected void refreshSemantic() {
+ if (resolveSemanticElement() == null) {
+ return;
+ }
+ LinkedList<IAdaptable> createdViews = new LinkedList<IAdaptable>();
+ List<TOENodeDescriptor> childDescriptors = TOEDiagramUpdater.getDepartmentDepartment_staff_7001SemanticChildren((View) getHost().getModel());
+ LinkedList<View> orphaned = new LinkedList<View>();
+ // we care to check only views we recognize as ours
+ LinkedList<View> knownViewChildren = new LinkedList<View>();
+ for (View v : getViewChildren()) {
+ if (isMyDiagramElement(v)) {
+ knownViewChildren.add(v);
+ }
+ }
+ // alternative to #cleanCanonicalSemanticChildren(getViewChildren(), semanticChildren)
+ //
+ // iteration happens over list of desired semantic elements, trying to find best matching View, while original CEP
+ // iterates views, potentially losing view (size/bounds) information - i.e. if there are few views to reference same EObject, only last one
+ // to answer isOrphaned == true will be used for the domain element representation, see #cleanCanonicalSemanticChildren()
+ for (Iterator<TOENodeDescriptor> descriptorsIterator = childDescriptors.iterator(); descriptorsIterator.hasNext();) {
+ TOENodeDescriptor next = descriptorsIterator.next();
+ String hint = TOEVisualIDRegistry.getType(next.getVisualID());
+ LinkedList<View> perfectMatch = new LinkedList<View>(); // both semanticElement and hint match that of NodeDescriptor
+ for (View childView : getViewChildren()) {
+ EObject semanticElement = childView.getElement();
+ if (next.getModelElement().equals(semanticElement)) {
+ if (hint.equals(childView.getType())) {
+ perfectMatch.add(childView);
+ // actually, can stop iteration over view children here, but
+ // may want to use not the first view but last one as a 'real' match (the way original CEP does
+ // with its trick with viewToSemanticMap inside #cleanCanonicalSemanticChildren
+ }
+ }
+ }
+ if (perfectMatch.size() > 0) {
+ descriptorsIterator.remove(); // precise match found no need to create anything for the NodeDescriptor
+ // use only one view (first or last?), keep rest as orphaned for further consideration
+ knownViewChildren.remove(perfectMatch.getFirst());
+ }
+ }
+ // those left in knownViewChildren are subject to removal - they are our diagram elements we didn't find match to,
+ // or those we have potential matches to, and thus need to be recreated, preserving size/location information.
+ orphaned.addAll(knownViewChildren);
+ //
+ ArrayList<CreateViewRequest.ViewDescriptor> viewDescriptors = new ArrayList<CreateViewRequest.ViewDescriptor>(childDescriptors.size());
+ for (TOENodeDescriptor next : childDescriptors) {
+ String hint = TOEVisualIDRegistry.getType(next.getVisualID());
+ IAdaptable elementAdapter = new CanonicalElementAdapter(next.getModelElement(), hint);
+ CreateViewRequest.ViewDescriptor descriptor = new CreateViewRequest.ViewDescriptor(elementAdapter, Node.class, hint, ViewUtil.APPEND, false, host().getDiagramPreferencesHint());
+ viewDescriptors.add(descriptor);
+ }
+
+ boolean changed = deleteViews(orphaned.iterator());
+ //
+ CreateViewRequest request = getCreateViewRequest(viewDescriptors);
+ Command cmd = getCreateViewCommand(request);
+ if (cmd != null && cmd.canExecute()) {
+ SetViewMutabilityCommand.makeMutable(new EObjectAdapter(host().getNotationView())).execute();
+ executeCommand(cmd);
+ @SuppressWarnings("unchecked")
+ List<IAdaptable> nl = (List<IAdaptable>) request.getNewObject();
+ createdViews.addAll(nl);
+ }
+ if (changed || createdViews.size() > 0) {
+ postProcessRefreshSemantic(createdViews);
+ }
+ if (createdViews.size() > 1) {
+ // perform a layout of the container
+ DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
+ executeCommand(new ICommandProxy(layoutCmd));
+ }
+
+ makeViewsImmutable(createdViews);
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffItemSemanticEditPolicy.java
new file mode 100644
index 000000000..7d5163f8e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentDepartment_staffItemSemanticEditPolicy.java
@@ -0,0 +1,34 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.Department2CreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.Employee2CreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+
+/**
+* @generated
+*/
+public class DepartmentDepartment_staffItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DepartmentDepartment_staffItemSemanticEditPolicy() {
+ super(TOEElementTypes.Department_2002);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateCommand(CreateElementRequest req) {
+ if (TOEElementTypes.Employee_3001 == req.getElementType()) {
+ return getGEFWrapper(new Employee2CreateCommand(req));
+ }
+ if (TOEElementTypes.Department_3002 == req.getElementType()) {
+ return getGEFWrapper(new Department2CreateCommand(req));
+ }
+ return super.getCreateCommand(req);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentItemSemanticEditPolicy.java
new file mode 100644
index 000000000..2627d23a5
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentItemSemanticEditPolicy.java
@@ -0,0 +1,159 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerManagedDepartmentCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerManagedDepartmentReorientCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ContributionEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Department2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentDepartment_staffEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerManagedDepartmentEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.common.core.command.ICompositeCommand;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class DepartmentItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public DepartmentItemSemanticEditPolicy() {
+ super(TOEElementTypes.Department_2002);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(false);
+ for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(incomingLink) == ManagerManagedDepartmentEditPart.VISUAL_ID) {
+ DestroyReferenceRequest r = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
+ continue;
+ }
+ }
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: false
+ addDestroyChildNodesCommand(cmd);
+ addDestroyShortcutsCommand(cmd, view);
+ // delete host element
+ cmd.add(new DestroyElementCommand(req));
+ } else {
+ cmd.add(new DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ private void addDestroyChildNodesCommand(ICompositeCommand cmd) {
+ View view = (View) getHost().getModel();
+ for (Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
+ Node node = (Node) nit.next();
+ switch (TOEVisualIDRegistry.getVisualID(node)) {
+ case DepartmentDepartment_staffEditPart.VISUAL_ID:
+ for (Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ Node cnode = (Node) cit.next();
+ switch (TOEVisualIDRegistry.getVisualID(cnode)) {
+ case Employee2EditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(outgoingLink) == ContributionEditPart.VISUAL_ID) {
+ DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+ }
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of cnode as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
+ break;
+ case Department2EditPart.VISUAL_ID:
+ for (Iterator<?> it = cnode.getTargetEdges().iterator(); it.hasNext();) {
+ Edge incomingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(incomingLink) == ManagerManagedDepartmentEditPart.VISUAL_ID) {
+ DestroyReferenceRequest r = new DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), incomingLink));
+ continue;
+ }
+ }
+ cmd.add(new DestroyElementCommand(new DestroyElementRequest(getEditingDomain(), cnode.getElement(), false))); // directlyOwned: true
+ // don't need explicit deletion of cnode as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), cnode));
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.ManagerManagedDepartment_4001 == req.getElementType()) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.ManagerManagedDepartment_4001 == req.getElementType()) {
+ return getGEFWrapper(new ManagerManagedDepartmentCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * Returns command to reorient EReference based link. New link target or source
+ * should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ManagerManagedDepartmentEditPart.VISUAL_ID:
+ return getGEFWrapper(new ManagerManagedDepartmentReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground2002Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground2002Policy.java
new file mode 100644
index 000000000..119b84711
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground2002Policy.java
@@ -0,0 +1,55 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentEditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+import org.eclipse.ocl.util.Tuple;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class DepartmentPinForeground2002Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentPinForeground2002Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public DepartmentPinForeground2002Policy() {
+ super(OclTrackerFactory.Type.IMPACT_ANALYZER);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ Tuple<?, ?> tupleValue = (Tuple<?, ?>) value;
+ Integer red = (Integer) tupleValue.getValue("red");
+ Integer green = (Integer) tupleValue.getValue("green");
+ Integer blue = (Integer) tupleValue.getValue("blue");
+ Color color = new Color(null, red, green, blue);
+ getHostImpl().getPrimaryShape().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected DepartmentEditPart getHostImpl() {
+ return (DepartmentEditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return "--IA\r\nlet totalSalary : Integer = self.employees->iterate(\r\ne: Employee; sum : Integer = 0 | \r\nsum + e.salary\r\n) in \r\nif totalSalary > 10000 \r\nthen Tuple {red: Integer = 255, green: Integer = 0, blue: Integer = 0} \r\nelse Tuple {red: Integer = 0, green: Integer = 255, blue: Integer = 0} \r\nendif"; //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground3002Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground3002Policy.java
new file mode 100644
index 000000000..faea069fe
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/DepartmentPinForeground3002Policy.java
@@ -0,0 +1,55 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Department2EditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+import org.eclipse.ocl.util.Tuple;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class DepartmentPinForeground3002Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.DepartmentPinForeground3002Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public DepartmentPinForeground3002Policy() {
+ super(OclTrackerFactory.Type.IMPACT_ANALYZER);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ Tuple<?, ?> tupleValue = (Tuple<?, ?>) value;
+ Integer red = (Integer) tupleValue.getValue("red");
+ Integer green = (Integer) tupleValue.getValue("green");
+ Integer blue = (Integer) tupleValue.getValue("blue");
+ Color color = new Color(null, red, green, blue);
+ getHostImpl().getPrimaryShape().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Department2EditPart getHostImpl() {
+ return (Department2EditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return "--IA\r\nlet totalSalary : Integer = self.employees->iterate(\r\ne: Employee; sum : Integer = 0 | \r\nsum + e.salary\r\n) in \r\nif totalSalary > 10000 \r\nthen Tuple {red: Integer = 255, green: Integer = 0, blue: Integer = 0} \r\nelse Tuple {red: Integer = 0, green: Integer = 255, blue: Integer = 0} \r\nendif"; //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Employee2ItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Employee2ItemSemanticEditPolicy.java
new file mode 100644
index 000000000..a784f2aea
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/Employee2ItemSemanticEditPolicy.java
@@ -0,0 +1,103 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ContributionCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ContributionReorientCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ContributionEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class Employee2ItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public Employee2ItemSemanticEditPolicy() {
+ super(TOEElementTypes.Employee_3001);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(false);
+ for (Iterator<?> it = view.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(outgoingLink) == ContributionEditPart.VISUAL_ID) {
+ DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+ }
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: false
+ addDestroyShortcutsCommand(cmd, view);
+ // delete host element
+ cmd.add(new DestroyElementCommand(req));
+ } else {
+ cmd.add(new DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.Contribution_4003 == req.getElementType()) {
+ return getGEFWrapper(new ContributionCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.Contribution_4003 == req.getElementType()) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * Returns command to reorient EClass based link. New link target or source
+ * should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ContributionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContributionReorientCommand(req));
+ }
+ return super.getReorientRelationshipCommand(req);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeeItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeeItemSemanticEditPolicy.java
new file mode 100644
index 000000000..0ed822973
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeeItemSemanticEditPolicy.java
@@ -0,0 +1,103 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ContributionCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ContributionReorientCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ContributionEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class EmployeeItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public EmployeeItemSemanticEditPolicy() {
+ super(TOEElementTypes.Employee_2001);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(false);
+ for (Iterator<?> it = view.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(outgoingLink) == ContributionEditPart.VISUAL_ID) {
+ DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+ }
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: false
+ addDestroyShortcutsCommand(cmd, view);
+ // delete host element
+ cmd.add(new DestroyElementCommand(req));
+ } else {
+ cmd.add(new DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.Contribution_4003 == req.getElementType()) {
+ return getGEFWrapper(new ContributionCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.Contribution_4003 == req.getElementType()) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * Returns command to reorient EClass based link. New link target or source
+ * should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ContributionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContributionReorientCommand(req));
+ }
+ return super.getReorientRelationshipCommand(req);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter2001Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter2001Policy.java
new file mode 100644
index 000000000..3fed82276
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter2001Policy.java
@@ -0,0 +1,48 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeEditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+
+/**
+ * @generated
+ */
+public class EmployeePinCounter2001Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinCounter2001Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public EmployeePinCounter2001Policy() {
+ super();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ getHostImpl().getPrimaryShape().getInnerEmployeeFigure().setCounter((Integer) value);
+
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected EmployeeEditPart getHostImpl() {
+ return (EmployeeEditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return "self.projects->size()"; //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter3001Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter3001Policy.java
new file mode 100644
index 000000000..c81381847
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinCounter3001Policy.java
@@ -0,0 +1,48 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+
+/**
+ * @generated
+ */
+public class EmployeePinCounter3001Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinCounter3001Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public EmployeePinCounter3001Policy() {
+ super();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ getHostImpl().getPrimaryShape().getInnerEmployeeFigure().setCounter((Integer) value);
+
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Employee2EditPart getHostImpl() {
+ return (Employee2EditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return "self.projects->size()"; //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible2001Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible2001Policy.java
new file mode 100644
index 000000000..09f7c4b68
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible2001Policy.java
@@ -0,0 +1,48 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.EmployeeEditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+
+/**
+ * @generated
+ */
+public class EmployeePinVisible2001Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinVisible2001Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public EmployeePinVisible2001Policy() {
+ super();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ getHostImpl().getPrimaryShape().getInnerEmployeeFigure().setVisible((Boolean) value);
+
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected EmployeeEditPart getHostImpl() {
+ return (EmployeeEditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return "self.projects->size() <> 0"; //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible3001Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible3001Policy.java
new file mode 100644
index 000000000..c5c322ab6
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/EmployeePinVisible3001Policy.java
@@ -0,0 +1,48 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.Employee2EditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+
+/**
+ * @generated
+ */
+public class EmployeePinVisible3001Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.EmployeePinVisible3001Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public EmployeePinVisible3001Policy() {
+ super();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ getHostImpl().getPrimaryShape().getInnerEmployeeFigure().setVisible((Boolean) value);
+
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected Employee2EditPart getHostImpl() {
+ return (Employee2EditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return "self.projects->size() <> 0"; //$NON-NLS-1$
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinForeground4002Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinForeground4002Policy.java
new file mode 100644
index 000000000..3226c7e38
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinForeground4002Policy.java
@@ -0,0 +1,85 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Project;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerLeadsEditPart;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+import org.eclipse.ocl.util.Tuple;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @generated
+ */
+public class LeadsProjectConnectionPinForeground4002Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.LeadsProjectConnectionPinForeground4002Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public LeadsProjectConnectionPinForeground4002Policy() {
+ super();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ Tuple<?, ?> tupleValue = (Tuple<?, ?>) value;
+ Integer red = (Integer) tupleValue.getValue("red");
+ Integer green = (Integer) tupleValue.getValue("green");
+ Integer blue = (Integer) tupleValue.getValue("blue");
+ Color color = new Color(null, red, green, blue);
+ getHostImpl().getPrimaryShape().setForegroundColor(color);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ManagerLeadsEditPart getHostImpl() {
+ return (ManagerLeadsEditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return " let _src : Manager = self.lead in " //
+ + " let _dst : Project = self in " //
+ + "if _src.leads->size() > 2\r\nthen Tuple {red: Integer = 255, green: Integer = 128, blue: Integer = 0} \r\nelse Tuple {red: Integer = 255, green: Integer =0, blue: Integer = 0} \r\nendif"; //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected EObject getContext() {
+ Edge hostModel = (Edge) host().getModel();
+ View targetModel = hostModel.getTarget();
+ View sourceModel = hostModel.getSource();
+
+ if (targetModel == null || sourceModel == null) {
+ return null;
+ }
+
+ EObject targetSemanticModel = ViewUtil.resolveSemanticElement(targetModel);
+ // need to check actual opposite of the semantic element, since diagram opposite could be not up to date
+ Project targetTypedModel = (Project) targetSemanticModel;
+ EObject sourceSemanticModel = targetTypedModel.getLead();
+
+ if (sourceSemanticModel == null) {
+ return null;
+ }
+
+ return targetSemanticModel;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinLineWidth4002Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinLineWidth4002Policy.java
new file mode 100644
index 000000000..b9711d88e
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/LeadsProjectConnectionPinLineWidth4002Policy.java
@@ -0,0 +1,80 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.examples.ocldriven.toe.Project;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerLeadsEditPart;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+
+/**
+ * @generated
+ */
+public class LeadsProjectConnectionPinLineWidth4002Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.LeadsProjectConnectionPinLineWidth4002Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public LeadsProjectConnectionPinLineWidth4002Policy() {
+ super(OclTrackerFactory.Type.IMPACT_ANALYZER);
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ getHostImpl().getPrimaryShape().setLineWidth((Integer) value);
+
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected ManagerLeadsEditPart getHostImpl() {
+ return (ManagerLeadsEditPart) super.getHostImpl();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getExpressionBody() {
+ return " let _src : Manager = self.lead in " //
+ + " let _dst : Project = self in " //
+ + "--IA\r\nif _src.leads->size() > 2\r\nthen 3\r\nelse 1\r\nendif"; //$NON-NLS-1$
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected EObject getContext() {
+ Edge hostModel = (Edge) host().getModel();
+ View targetModel = hostModel.getTarget();
+ View sourceModel = hostModel.getSource();
+
+ if (targetModel == null || sourceModel == null) {
+ return null;
+ }
+
+ EObject targetSemanticModel = ViewUtil.resolveSemanticElement(targetModel);
+ // need to check actual opposite of the semantic element, since diagram opposite could be not up to date
+ Project targetTypedModel = (Project) targetSemanticModel;
+ EObject sourceSemanticModel = targetTypedModel.getLead();
+
+ if (sourceSemanticModel == null) {
+ return null;
+ }
+
+ return targetSemanticModel;
+ }
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerItemSemanticEditPolicy.java
new file mode 100644
index 000000000..9cea98d56
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerItemSemanticEditPolicy.java
@@ -0,0 +1,152 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ContributionCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ContributionReorientCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerLeadsCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerLeadsReorientCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerManagedDepartmentCreateCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.commands.ManagerManagedDepartmentReorientCommand;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ContributionEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerLeadsEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerManagedDepartmentEditPart;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @generated
+ */
+public class ManagerItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ManagerItemSemanticEditPolicy() {
+ super(TOEElementTypes.Manager_2004);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyElementCommand(DestroyElementRequest req) {
+ View view = (View) getHost().getModel();
+ CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null);
+ cmd.setTransactionNestingEnabled(false);
+ for (Iterator<?> it = view.getSourceEdges().iterator(); it.hasNext();) {
+ Edge outgoingLink = (Edge) it.next();
+ if (TOEVisualIDRegistry.getVisualID(outgoingLink) == ManagerManagedDepartmentEditPart.VISUAL_ID) {
+ DestroyReferenceRequest r = new DestroyReferenceRequest(outgoingLink.getSource().getElement(), null, outgoingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+ if (TOEVisualIDRegistry.getVisualID(outgoingLink) == ManagerLeadsEditPart.VISUAL_ID) {
+ DestroyReferenceRequest r = new DestroyReferenceRequest(outgoingLink.getSource().getElement(), null, outgoingLink.getTarget().getElement(), false);
+ cmd.add(new DestroyReferenceCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+ if (TOEVisualIDRegistry.getVisualID(outgoingLink) == ContributionEditPart.VISUAL_ID) {
+ DestroyElementRequest r = new DestroyElementRequest(outgoingLink.getElement(), false);
+ cmd.add(new DestroyElementCommand(r));
+ cmd.add(new DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+ }
+ EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: false
+ addDestroyShortcutsCommand(cmd, view);
+ // delete host element
+ cmd.add(new DestroyElementCommand(req));
+ } else {
+ cmd.add(new DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cmd.reduce());
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCreateRelationshipCommand(CreateRelationshipRequest req) {
+ Command command = req.getTarget() == null ? getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
+ return command != null ? command : super.getCreateRelationshipCommand(req);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getStartCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.ManagerManagedDepartment_4001 == req.getElementType()) {
+ return getGEFWrapper(new ManagerManagedDepartmentCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ if (TOEElementTypes.ManagerLeads_4002 == req.getElementType()) {
+ return getGEFWrapper(new ManagerLeadsCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ if (TOEElementTypes.Contribution_4003 == req.getElementType()) {
+ return getGEFWrapper(new ContributionCreateCommand(req, req.getSource(), req.getTarget()));
+ }
+ return null;
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getCompleteCreateRelationshipCommand(CreateRelationshipRequest req) {
+ if (TOEElementTypes.ManagerManagedDepartment_4001 == req.getElementType()) {
+ return null;
+ }
+ if (TOEElementTypes.ManagerLeads_4002 == req.getElementType()) {
+ return null;
+ }
+ if (TOEElementTypes.Contribution_4003 == req.getElementType()) {
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ * Returns command to reorient EClass based link. New link target or source
+ * should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ protected Command getReorientRelationshipCommand(ReorientRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ContributionEditPart.VISUAL_ID:
+ return getGEFWrapper(new ContributionReorientCommand(req));
+ }
+ return super.getReorientRelationshipCommand(req);
+ }
+
+ /**
+ * Returns command to reorient EReference based link. New link target or source
+ * should be the domain model element associated with this node.
+ *
+ * @generated
+ */
+ protected Command getReorientReferenceRelationshipCommand(ReorientReferenceRelationshipRequest req) {
+ switch (getVisualID(req)) {
+ case ManagerManagedDepartmentEditPart.VISUAL_ID:
+ return getGEFWrapper(new ManagerManagedDepartmentReorientCommand(req));
+ case ManagerLeadsEditPart.VISUAL_ID:
+ return getGEFWrapper(new ManagerLeadsReorientCommand(req));
+ }
+ return super.getReorientReferenceRelationshipCommand(req);
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerLeadsItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerLeadsItemSemanticEditPolicy.java
new file mode 100644
index 000000000..8a3603a4d
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerLeadsItemSemanticEditPolicy.java
@@ -0,0 +1,27 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+
+/**
+ * @generated
+ */
+public class ManagerLeadsItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ManagerLeadsItemSemanticEditPolicy() {
+ super(TOEElementTypes.ManagerLeads_4002);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
+ return getGEFWrapper(new DestroyReferenceCommand(req));
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerManagedDepartmentItemSemanticEditPolicy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerManagedDepartmentItemSemanticEditPolicy.java
new file mode 100644
index 000000000..d83a09e9a
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerManagedDepartmentItemSemanticEditPolicy.java
@@ -0,0 +1,27 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.providers.TOEElementTypes;
+import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest;
+
+/**
+ * @generated
+ */
+public class ManagerManagedDepartmentItemSemanticEditPolicy extends TOEBaseItemSemanticEditPolicy {
+
+ /**
+ * @generated
+ */
+ public ManagerManagedDepartmentItemSemanticEditPolicy() {
+ super(TOEElementTypes.ManagerManagedDepartment_4001);
+ }
+
+ /**
+ * @generated
+ */
+ protected Command getDestroyReferenceCommand(DestroyReferenceRequest req) {
+ return getGEFWrapper(new DestroyReferenceCommand(req));
+ }
+
+}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerPinBackgroundRGB2004Policy.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerPinBackgroundRGB2004Policy.java
new file mode 100644
index 000000000..7c69bd1d1
--- /dev/null
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/src/org/eclipse/gmf/examples/ocldriven/toe/diagram/edit/policies/ManagerPinBackgroundRGB2004Policy.java
@@ -0,0 +1,54 @@
+package org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies;
+
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.ManagerEditPart;
+import org.eclipse.gmf.tooling.runtime.edit.policies.effect.AbstractOclVisualEffectEditPolicy;
+import org.eclipse.ocl.util.Tuple;
+
+/**
+ * @generated
+ */
+public class ManagerPinBackgroundRGB2004Policy extends AbstractOclVisualEffectEditPolicy {
+
+ /**
+ * @generated
+ */
+ public static final String KEY = "org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.policies.ManagerPinBackgroundRGB2004Policy:KEY";
+
+ /**
+ * @generated
+ */
+ public ManagerPinBackgroundRGB2004Policy() {
+ super();
+ }
+
+ /**
+ * @generated
+ */
+ @Override
+ protected void setVisualEffectValue(Object value) {
+ Tuple<?, ?> tupleValue = (Tuple<?, ?>) value;
+ Integer red = (Integer) tupleValue.getValue("red");
+ Integer green = (Integer) t